-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Implement more native file I/O #10495
Conversation
@alexcrichton If you have a native HANDLE on Windows, you can use [SetFilePointerEx](http://msdn.microsoft.com/en-us/library/windows/desktop/aa365542(v=vs.85\).aspx) and [SetEndOfFile](http://msdn.microsoft.com/en-us/library/windows/desktop/aa365531(v=vs.85\).aspx) to truncate, FWIW. |
Just building on this: you can use [_get_osfhandle](http://msdn.microsoft.com/en-us/library/aa297958(v=vs.60\).aspx) to get the underlying HANDLE, and then use the above Win32 APIs. |
@andrew-d, amazing! I will implement it as such before merging this. |
Thanks to @andrew-d's suggestion, truncate is now implemented! |
By the way, we could outsource a lot of these Windows porting efforts by switching to mingw-w64. They have a much larger suite of POSIX functions implemented than mingw (including ones like |
If we dropped the mingw dependency completely, would we still have the old POSIX functionality implemented natively by windows? |
No, we wouldn't, but we can't drop the mingw runtime if we don't want to make a C99 math library or find an alternative (and more). Unlike the legacy mingw, mingw-w64 is a solid and very actively developed runtime providing the best C++11 support on Windows via gcc. |
|
This implements a fair amount of the unimpl() functionality in io::native relating to filesystem operations. I've also modified all io::fs tests to run in both a native and uv environment (so everything is actually tested). There are a two bits of remaining functionality which I was unable to get working: * change_file_times on windows * lstat on windows I think that change_file_times may just need a better interface, but lstat has a large implementation in libuv which I didn't want to tackle trying to copy.
This implements a fair amount of the unimpl() functionality in io::native relating to filesystem operations. I've also modified all io::fs tests to run in both a native and uv environment (so everything is actually tested). There are a few bits of remaining functionality which I was unable to get working: * truncate on windows * change_file_times on windows * lstat on windows I think that change_file_times may just need a better interface, but the other two have large implementations in libuv which I didn't want to tackle trying to copy. I found a `chsize` function to work for truncate on windows, but it doesn't quite seem to be working out.
This implements a fair amount of the unimpl() functionality in io::native
relating to filesystem operations. I've also modified all io::fs tests to run in
both a native and uv environment (so everything is actually tested).
There are a few bits of remaining functionality which I was unable to get
working:
I think that change_file_times may just need a better interface, but the other
two have large implementations in libuv which I didn't want to tackle trying to
copy. I found a
chsize
function to work for truncate on windows, but itdoesn't quite seem to be working out.