Skip to content

os.file: Fix os file tell for windows#24218

Merged
spytheman merged 8 commits into
vlang:masterfrom
kbkpbot:fix-os-file-tell-windows
May 20, 2025
Merged

os.file: Fix os file tell for windows#24218
spytheman merged 8 commits into
vlang:masterfrom
kbkpbot:fix-os-file-tell-windows

Conversation

@kbkpbot

@kbkpbot kbkpbot commented Apr 14, 2025

Copy link
Copy Markdown
Contributor

Fix issue #24217

@huly-for-github

Copy link
Copy Markdown

Connected to Huly®: V_0.6-22601

@kbkpbot kbkpbot linked an issue Apr 14, 2025 that may be closed by this pull request
@kbkpbot

kbkpbot commented Apr 14, 2025

Copy link
Copy Markdown
Contributor Author

It seems that fd and cfile maintain their own position pointer.
If file is opened in buffer mode, these pointer may de-synchronize.

fd := C._wopen(p.to_wide(), flags, permission);

cfile := C.fdopen(fd, &char(mode.str));

C._fseeki64(cfile, 0, C.SEEK_END);

x := C._telli64(fd);

y := C._ftelli64(cfile);

// x y may different, not sure.

@spytheman

Copy link
Copy Markdown
Contributor

@kbkpbot, 3354c11 passed the CI, can we merge it?

@kbkpbot

kbkpbot commented May 19, 2025

Copy link
Copy Markdown
Contributor Author

I think this PR can merge now.

@spytheman spytheman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work.
I tried with msvc, clang, gcc, and tcc, all worked.

@spytheman

Copy link
Copy Markdown
Contributor

image

@spytheman spytheman merged commit c72d77d into vlang:master May 20, 2025
74 checks passed
@kbkpbot kbkpbot deleted the fix-os-file-tell-windows branch May 31, 2025 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[os] file read cause file position error under Windows

2 participants