Skip to content
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

Make retrieval of file size more portable #234

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

saxbophone
Copy link
Owner

Put sxbp_get_file_size() in a separate source file and used conditional compilation to provide three different implementations of it:

  • A POSIX/UNIX version which uses POSIX fstat()
  • A Windows version which uses GetFileSizeEx() (and associated other WinAPI functions)
  • A generic version using just the C standard library (but which might not work, as it uses fseek() and SEEK_END, which isn't required to be supported meaningfully).

TODO:

  • Test this on Windows
  • Amend Windows version to return failure if file size > 2GiB on Win32 only, not Win64

// return the calculated file size
return SXBP_RESULT_OK;
}
#endif
Copy link
Owner Author

Choose a reason for hiding this comment

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

I don't like this generic version. It does things in a fundamentally different way to the others. I think it should be removed instead.

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.

None yet

1 participant