[Commented On] D12580: rust-dirstate-v2: save proper data size if no new data on append
aalekseyev (Arseniy Alekseyev)
phabricator at mercurial-scm.org
Thu Apr 21 15:11:50 UTC 2022
aalekseyev added a comment.
Ok, I get it. You're saying size 0 is special because a write of size 0 does not update the current file pointer.
I did not know exactly how append mode interacted with lseek, so I did an experiment.
The following C program always prints "hi2" for me, even if redirected to a file in append mode.
I think this means that even though write in append mode always appends to the end of the file, it doesn't actually advance the file pointer to that position, so the returned value is effectively the amount you wrote, not the total size of the file.
(I did not try the same in rust)
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
int main() {
write(1, "hi", 2);
off_t pos = lseek(1, 0, SEEK_CUR);
printf("%ld\n", pos);
return 0;
}
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D12580/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D12580
To: Alphare, #hg-reviewers
Cc: aalekseyev, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20220421/5c2a0acd/attachment-0002.html>
More information about the Mercurial-patches
mailing list