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

Issues with file_size #3

Open
Gugap opened this issue Jan 31, 2019 · 1 comment
Open

Issues with file_size #3

Gugap opened this issue Jan 31, 2019 · 1 comment

Comments

@Gugap
Copy link

Gugap commented Jan 31, 2019

std::uintmax_t file_size( path const & p )

Do not retrieve size by opening a handle and by calling GetFileSizeEx.
Instead use the GetFileAttributesExA, which doesn't need an open handle and is basically a wrapper for the NtQueryFullAttributesFile syscall.
It is faster by the order of a magnitude.

Also the return of "-1" with return type of uintmax_t is a bug as its unsigned and checking if the return value is < 0 will never true (Technically you could still check for == -1, but it is not a good design as the return type does imply otherwise).
Throw instead, or use optional or some other way to signal an error.

@iamOgunyinka
Copy link
Owner

Thank you! It's my first time writing code using pure Win32 and most(if not all) of the implementation are naïve, so I'll make the necessary adjustments where necessary. Please note that the code as-is doesn't compile and haven't been tested AT ALL, so a lot of it will be changing before I declare it usable.

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

No branches or pull requests

2 participants