1 | // raise flag to stop |
2 | static Flag tailFile(final File file, final int interval, fO onData) { |
3 | final new Flag flag; |
4 | thread "Tail File" { |
5 | long l = 0; |
6 | repeat with ms sleep interval { |
7 | pcall { |
8 | long l2 = l(file); |
9 | if (l2 < l) l = 0; |
10 | if (l2 != l) pcall { |
11 | S text = null; |
12 | pcall { |
13 | text = loadTextFilePart(file, l, l2); |
14 | } |
15 | if (nempty(text)) |
16 | callF(onData, text); |
17 | l = l2; |
18 | } |
19 | } |
20 | if (flag.isUp()) break; // break AFTER we checked for new data |
21 | } |
22 | } |
23 | ret flag; |
24 | } |
Began life as a copy of #1006740
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): cfunsshuasjs, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1011587 |
Snippet name: | tailFile (old) |
Eternal ID of this version: | #1011587/1 |
Text MD5: | d2de86ed301b6bf2f0f175b8b14a664a |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | Yes |
Created/modified: | 2017-10-31 18:57:59 |
Source code size: | 605 bytes / 24 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 324 / 332 |
Referenced in: | [show references] |