zturner added inline comments.
================
Comment at: source/Host/common/File.cpp:405
- if (bytes_read == 0) {
- if (::feof(m_stream))
- error.SetErrorString("feof");
- else if (::ferror(m_stream))
- error.SetErrorString("ferror");
- num_bytes = 0;
- } else
- num_bytes = bytes_read;
- } else {
- num_bytes = 0;
- error.SetErrorString("invalid file handle");
- }
- return error;
+ off_t offset = lseek(fd, 0, SEEK_CUR);
+ return Read(buf, num_bytes, offset);
----------------
clayborg wrote:
> Why are we calling lseek when we are passing the offset into the read below?
>
> Shouldn't this just be:
> ```
> off_t offset = 0;
> ```
This `lseek` is to get the current file pointer. If someone calls `Write()`
with no offset, they expect this to mean "write at the current file position".
In order to do that with `pwrite()`, you need to know what the current file
position actually is. If we just set `offset=0`, it will write at the
beginning of the file, which is probably not the intention.
LMK if I've misunderstood.
https://reviews.llvm.org/D25783
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits