Added support for read_file() to read lines from end of file#797
Added support for read_file() to read lines from end of file#797thefallentree merged 2 commits intofluffos:masterfrom
Conversation
|
Added support for Example: read_file("/some_file", -10) The above example would read the file starting 10 lines from the end of the file. |
src/packages/core/file.cc
Outdated
| if (*ptr_start == '\0') { | ||
| debug(file, "read_file: file contains '\\0': %s.\n", file); | ||
| return nullptr; | ||
| const char *ptr_start; |
There was a problem hiding this comment.
I think you still want const char *ptr_start = theBuff;
otherwise read_file(0, 1) will fail
There was a problem hiding this comment.
I have ptr_start = theBuff; below that for if the line parameter is a positive number, and ptr_start = theBuff + total_bytes_read; if it is negative.
|
I will update the docs once this has merged. |
| mid = implode(explode(foo, "\n")[<14..<5], "\n") + "\n"; | ||
| ASSERT_EQ(mid, read_file("/testfile", -15, 10)); | ||
| // if we start too many lines before the end of the file, start at the beginning | ||
| ASSERT(read_file("/testfile", -10000, 1)); |
There was a problem hiding this comment.
i think you want ASSERT_EQ(implode(explode(foo, "\n")[0..0], read_file(...) )
|
and here is the crash logs: |
|
Thanks for the crash log. It looks like checks are passing now. |
…#797) * Added support for read_file() to read lines from end of file * changed out ptr_start was assigned in read_file()
No description provided.