mirror of
https://github.com/uutils/coreutils
synced 2024-11-15 09:27:21 +00:00
tail: When tailing a file in bytes mode, seek directly to the specified byte
When tailing a file, as opposed to stdin, and we are tailing bytes rather than lines, we can seek the requested number of bytes from the end of the file. This side steps the whole `backwards_thru_file` file loop and blocks of reads. Fixes #833.
This commit is contained in:
parent
f851611001
commit
2b2c2b64c2
1 changed files with 2 additions and 5 deletions
|
@ -336,11 +336,8 @@ fn bounded_tail(mut file: File, settings: &Settings) {
|
|||
}
|
||||
});
|
||||
},
|
||||
FilterMode::Bytes(mut count) => {
|
||||
backwards_thru_file(&mut file, size, &mut buf, &mut |_| {
|
||||
count -= 1;
|
||||
count == 0
|
||||
});
|
||||
FilterMode::Bytes(count) => {
|
||||
file.seek(SeekFrom::End(-(count as i64))).unwrap();
|
||||
},
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue