Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 20, 2025

Conversation

kbkpbot
Copy link
Contributor

@kbkpbot kbkpbot commented Apr 14, 2025

Fix issue #24217

Copy link

Connected to Huly®: V_0.6-22601

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

kbkpbot commented Apr 14, 2025

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
Member

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

@kbkpbot
Copy link
Contributor Author

kbkpbot commented May 19, 2025

I think this PR can merge now.

Copy link
Member

@spytheman spytheman left a comment

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
Member

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