native: Improve windows file handling

This commit splits the file implementation into file_unix and file_win32. The
two implementations have diverged to the point that they share almost 0 code at
this point, so it's easier to maintain as separate files.

The other major change accompanied with this commit is that file::open is no
longer based on libc's open function on windows, but rather windows's CreateFile
function. This fixes dealing with binary files on windows (test added in
previous commit).

This also changes the read/write functions to use ReadFile and WriteFile instead
of libc's read/write.

Closes #12406
This commit is contained in:
Alex Crichton
2014-02-26 12:57:00 -08:00
parent 843c5e6308
commit cd9010c77e
11 changed files with 1146 additions and 1018 deletions

View File

@@ -17,8 +17,8 @@ use std::rt::rtio;
use std::sync::arc::UnsafeArc;
use std::intrinsics;
use super::{IoResult, retry};
use super::file::{keep_going, fd_t};
use super::{IoResult, retry, keep_going};
use super::file::fd_t;
fn unix_socket(ty: libc::c_int) -> IoResult<fd_t> {
match unsafe { libc::socket(libc::AF_UNIX, ty, 0) } {