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

Implement more native file I/O #10495

Merged
merged 1 commit into from
Nov 19, 2013
Merged

Conversation

alexcrichton
Copy link
Member

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.

@andrew-d
Copy link
Contributor

@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.

@andrew-d
Copy link
Contributor

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.

@alexcrichton
Copy link
Member Author

@andrew-d, amazing! I will implement it as such before merging this.

@alexcrichton
Copy link
Member Author

Thanks to @andrew-d's suggestion, truncate is now implemented!

@thestinger
Copy link
Contributor

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 ftruncate), and unlike mingw they actually work properly :P.

@alexcrichton
Copy link
Member Author

If we dropped the mingw dependency completely, would we still have the old POSIX functionality implemented natively by windows?

@thestinger
Copy link
Contributor

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.

@alexcrichton
Copy link
Member Author

utime moved into rust

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.
bors added a commit that referenced this pull request Nov 19, 2013
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.
@bors bors closed this Nov 19, 2013
@bors bors merged commit 68d5510 into rust-lang:master Nov 19, 2013
@alexcrichton alexcrichton deleted the more-native-io branch November 19, 2013 22: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.

4 participants