about summary refs log tree commit diff
path: root/src/libnative/io/file.rs
AgeCommit message (Collapse)AuthorLines
2014-02-27native: Improve windows file handlingAlex Crichton-995/+0
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
2014-02-24native: be more const correct with the FFI calls.Huon Wilson-1/+1
These calls are mutating their argument and so it's bad behaviour to be pretending that the values are immutable to rustc.
2014-02-21Changed NonCamelCaseTypes lint to warn by defaultmr.Shu-1/+3
Added allow(non_camel_case_types) to librustc where necesary Tried to fix problems with non_camel_case_types outside rustc fixed failing tests Docs updated Moved #[allow(non_camel_case_types)] a level higher. markdown.rs reverted Fixed timer that was failing tests Fixed another timer
2014-02-19str: add a function for truncating a vector of u16 at NUL.Huon Wilson-1/+2
Many of the functions interacting with Windows APIs allocate a vector of 0's and do not retrieve a length directly from the API call, and so need to be sure to remove the unmodified junk at the end of the vector.
2014-02-18std: make str::from_utf16 return an Option.Huon Wilson-1/+2
The rest of the codebase is moving toward avoiding `fail!` so we do it here too!
2014-02-09auto merge of #12136 : alexcrichton/rust/issue-12123, r=brsonbors-1/+1
Closes #12123
2014-02-09Fix the signature of CreateSymbolicLinkWAlex Crichton-1/+1
Closes #12123
2014-02-09std: Add init and uninit to mem. Replace direct intrinsic usageBrian Anderson-6/+6
2014-02-05Implement clone() for TCP/UDP/Unix socketsAlex Crichton-16/+31
This is part of the overall strategy I would like to take when approaching issue #11165. The only two I/O objects that reasonably want to be "split" are the network stream objects. Everything else can be "split" by just creating another version. The initial idea I had was the literally split the object into a reader and a writer half, but that would just introduce lots of clutter with extra interfaces that were a little unnnecssary, or it would return a ~Reader and a ~Writer which means you couldn't access things like the remote peer name or local socket name. The solution I found to be nicer was to just clone the stream itself. The clone is just a clone of the handle, nothing fancy going on at the kernel level. Conceptually I found this very easy to wrap my head around (everything else supports clone()), and it solved the "split" problem at the same time. The cloning support is pretty specific per platform/lib combination: * native/win32 - uses some specific WSA apis to clone the SOCKET handle * native/unix - uses dup() to get another file descriptor * green/all - This is where things get interesting. When we support full clones of a handle, this implies that we're allowing simultaneous writes and reads to happen. It turns out that libuv doesn't support two simultaneous reads or writes of the same object. It does support *one* read and *one* write at the same time, however. Some extra infrastructure was added to just block concurrent writers/readers until the previous read/write operation was completed. I've added tests to the tcp/unix modules to make sure that this functionality is supported everywhere.
2014-02-03Fixing remaining warnings and errors throughoutAlex Crichton-3/+5
2014-02-03native: Require all results are used and fix falloutAlex Crichton-5/+5
2014-02-03native: Remove io_error usageAlex Crichton-7/+4
2014-01-29Flag Result as #[must_use] and deal with fallout.Alex Crichton-12/+10
2014-01-26Removed all instances of XXX in preparation for relaxing of FIXME ruleSalem Talha-3/+3
2014-01-22libc: switch `free` to the proper signatureDaniel Micay-3/+3
This does not attempt to fully propagate the mutability everywhere, but gives new code a hint to avoid the same issues.
2014-01-21Remove unnecessary parentheses.Huon Wilson-2/+2
2014-01-17handle zero-size allocations correctlyDaniel Micay-2/+2
The `malloc` family of functions may return a null pointer for a zero-size allocation, which should not be interpreted as an out-of-memory error. If the implementation does not return a null pointer, then handling this will result in memory savings for zero-size types. This also switches some code to `malloc_raw` in order to maintain a centralized point for handling out-of-memory in `rt::global_heap`. Closes #11634
2014-01-09Remove eof() from io::ReaderAlex Crichton-1/+0
2014-01-06Don't read forever on a file descriptorAlex Crichton-4/+4
Similarly to the recent commit to do this for networking, there's no reason that a read on a file descriptor should continue reading until the entire buffer is full. This makes sense when dealing with literal files, but when dealing with things like stdin this doesn't make sense.
2014-01-05Handle EINTR throughout libnativeAlex Crichton-41/+59
Closes #11214
2013-12-27Implement native TCP I/OAlex Crichton-3/+5
2013-12-27Bring native process bindings up to dateAlex Crichton-3/+6
Move the tests into libstd, use the `iotest!` macro to test both native and uv bindings, and use the cloexec trick to figure out when the child process fails in exec.
2013-12-24native: Add tests and cleanup entry pointsAlex Crichton-2/+1
This adds a few smoke tests associated with libnative tasks (not much code to test here anyway), and cleans up the entry points a little bit to be a little more like libgreen. The I/O code doesn't need much testing because that's all tested in libstd (with the iotest! macro).
2013-12-24native: Introduce libnativeAlex Crichton-0/+958
This commit introduces a new crate called "native" which will be the crate that implements the 1:1 runtime of rust. This currently entails having an implementation of std::rt::Runtime inside of libnative as well as moving all of the native I/O implementations to libnative. The current snag is that the start lang item must currently be defined in libnative in order to start running, but this will change in the future. Cool fact about this crate, there are no extra features that are enabled. Note that this commit does not include any makefile support necessary for building libnative, that's all coming in a later commit.