about summary refs log tree commit diff
path: root/src/libstd/io
AgeCommit message (Collapse)AuthorLines
2014-03-13std: Rename Chan/Port types and constructorAlex Crichton-288/+246
* Chan<T> => Sender<T> * Port<T> => Receiver<T> * Chan::new() => channel() * constructor returns (Sender, Receiver) instead of (Receiver, Sender) * local variables named `port` renamed to `rx` * local variables named `chan` renamed to `tx` Closes #11765
2014-03-13auto merge of #12573 : lbonn/rust/unrecurs, r=alexcrichtonbors-11/+85
As mentioned in #6109, ```mkdir_recursive``` doesn't really need to use recursive calls, so here is an iterative version. The other points of the proposed overhaul (renaming and existing permissions) still need to be resolved. I also bundled an iterative ```rmdir_recursive```, for the same reason. Please do not hesitate to provide feedback on style as this is my first code change in rust.
2014-03-12auto merge of #12414 : DaGenix/rust/failing-iterator-wrappers, r=alexcrichtonbors-46/+53
Most IO related functions return an IoResult so that the caller can handle failure in whatever way is appropriate. However, the `lines`, `bytes`, and `chars` iterators all supress errors. This means that code that needs to handle errors can't use any of these iterators. All three of these iterators were updated to produce IoResults. Fixes #12368
2014-03-12Update io iterators to produce IoResultsPalmer Cox-46/+53
Most IO related functions return an IoResult so that the caller can handle failure in whatever way is appropriate. However, the `lines`, `bytes`, and `chars` iterators all supress errors. This means that code that needs to handle errors can't use any of these iterators. All three of these iterators were updated to produce IoResults. Fixes #12368
2014-03-12std: allow io::File* structs to be hashableErick Tryzelaar-1/+3
2014-03-12Remove remaining nolink usages.(fixes #12810)lpy-1/+0
2014-03-12doc: discuss try! in std::ioPeter Marheine-0/+34
2014-03-12Remove the dependence of std::io::test on rand.Huon Wilson-4/+11
This replaces it with a manual "task rng" using XorShift and a crappy seeding mechanism. Theoretically good enough for the purposes though (unique for tests).
2014-03-10fs: units tests for mkdir_recusive and rmdir_recursiveLaurent Bonnans-0/+26
The rmdir test is blocked by #12795 on windows.
2014-03-10fs: use an iterative algorithm for 'rmdir_recursive'Laurent Bonnans-8/+41
For now, the windows version uses stat, just as before. We should switch back to lstat as soon as #12795 is closed.
2014-03-10fs: use an iterative algorithm for 'mkdir_recursive'Laurent Bonnans-3/+18
as requested in #6109
2014-03-06fix typos with with repeated words, just like this sentence.Kang Seonghoon-4/+4
2014-03-04Rename struct fields with uppercase characters in their names to use lowercasePalmer Cox-4/+4
2014-03-04Rename all variables that have uppercase characters in their names to use ↵Palmer Cox-2/+2
only lowercase characters
2014-03-01std: Switch stdout/stderr to buffered by defaultAlex Crichton-5/+29
Similarly to #12422 which made stdin buffered by default, this commit makes the output streams also buffered by default. Now that buffered writers will flush their contents when they are dropped, I don't believe that there's no reason why the output shouldn't be buffered by default, which is what you want in 90% of cases. As with stdin, there are new stdout_raw() and stderr_raw() functions to get unbuffered streams to stdout/stderr.
2014-03-01std: Flush when buffered writers are droppedAlex Crichton-14/+25
It's still not entirely clear what should happen if there was an error when flushing, but I'm deferring that decision to #12628. I believe that it's crucial for the usefulness of buffered writers to be able to flush on drop. It's just too easy to forget to flush them in small one-off use cases. cc #12628
2014-02-28std: Change assert_eq!() to use {} instead of {:?}Alex Crichton-38/+38
Formatting via reflection has been a little questionable for some time now, and it's a little unfortunate that one of the standard macros will silently use reflection when you weren't expecting it. This adds small bits of code bloat to libraries, as well as not always being necessary. In light of this information, this commit switches assert_eq!() to using {} in the error message instead of {:?}. In updating existing code, there were a few error cases that I encountered: * It's impossible to define Show for [T, ..N]. I think DST will alleviate this because we can define Show for [T]. * A few types here and there just needed a #[deriving(Show)] * Type parameters needed a Show bound, I often moved this to `assert!(a == b)` * `Path` doesn't implement `Show`, so assert_eq!() cannot be used on two paths. I don't think this is much of a regression though because {:?} on paths looks awful (it's a byte array). Concretely speaking, this shaved 10K off a 656K binary. Not a lot, but sometime significant for smaller binaries.
2014-02-28std: Improve some I/O documentationAlex Crichton-33/+188
This lowers the #[allow(missing_doc)] directive into some of the lower modules which are less mature. Most I/O modules now require comprehensive documentation.
2014-02-27rustc: Use libnative for the compilerAlex Crichton-1/+1
The compiler itself doesn't necessarily need any features of green threading such as spawning tasks and lots of I/O, so libnative is slightly more appropriate for rustc to use itself. This should also help the rusti bot which is currently incompatible with libuv.
2014-02-27std: Small cleanup and test improvementAlex Crichton-150/+176
This weeds out a bunch of warnings building stdtest on windows, and it also adds a check! macro to the io::fs tests to help diagnose errors that are cropping up on windows platforms as well. cc #12516
2014-02-26auto merge of #12490 : zslayton/rust/doc-fix-12386, r=alexcrichtonbors-19/+9
Attn: @huonw Addresses #12386.
2014-02-25auto merge of #12522 : erickt/rust/hash, r=alexcrichtonbors-1/+0
This patch series does a couple things: * replaces manual `Hash` implementations with `#[deriving(Hash)]` * adds `Hash` back to `std::prelude` * minor cleanup of whitespace and variable names.
2014-02-24Remove std::from_str::FromStr from the preludeBrendan Zabarauskas-0/+1
2014-02-24std: minor whitespace cleanupErick Tryzelaar-1/+0
2014-02-24windows: Fix the test_exists unit testAlex Crichton-2/+5
Turns out the `timeout` command was exiting immediately because it didn't like its output piped. Instead use `ping` repeatedly to get a process that will sleep for awhile. cc #12516
2014-02-24Correctly ignore some tests on windowsAlex Crichton-6/+4
These two tests are notoriously flaky on the windows bots right now, so I'm ignoring them until I can investigate them some more. The truncate_works test has been flaky for quite some time, but it has gotten much worse recently. The test_exists test has been flaky since the recent std::run rewrite landed. Finally, the "unix pipe" test failure is a recent discovery on the try bots. I haven't seen this failing much, but better safe than sorry! cc #12516
2014-02-24auto merge of #12412 : alexcrichton/rust/deriving-show, r=huonwbors-54/+15
This commit removes deriving(ToStr) in favor of deriving(Show), migrating all impls of ToStr to fmt::Show. Most of the details can be found in the first commit message. Closes #12477
2014-02-23auto merge of #12380 : alexcrichton/rust/run-rewrite, r=brsonbors-79/+522
The std::run module is a relic from a standard library long since past, and there's not much use to having two modules to execute processes with where one is slightly more convenient. This commit merges the two modules, moving lots of functionality from std::run into std::io::process and then deleting std::run. New things you can find in std::io::process are: * Process::new() now only takes prog/args * Process::configure() takes a ProcessConfig * Process::status() is the same as run::process_status * Process::output() is the same as run::process_output * I/O for spawned tasks is now defaulted to captured in pipes instead of ignored * Process::kill() was added (plus an associated green/native implementation) * Process::wait_with_output() is the same as the old finish_with_output() * destroy() is now signal_exit() * force_destroy() is now signal_kill() Closes #2625 Closes #10016
2014-02-23Roll std::run into std::io::processAlex Crichton-79/+522
The std::run module is a relic from a standard library long since past, and there's not much use to having two modules to execute processes with where one is slightly more convenient. This commit merges the two modules, moving lots of functionality from std::run into std::io::process and then deleting std::run. New things you can find in std::io::process are: * Process::new() now only takes prog/args * Process::configure() takes a ProcessConfig * Process::status() is the same as run::process_status * Process::output() is the same as run::process_output * I/O for spawned tasks is now defaulted to captured in pipes instead of ignored * Process::kill() was added (plus an associated green/native implementation) * Process::wait_with_output() is the same as the old finish_with_output() * destroy() is now signal_exit() * force_destroy() is now signal_kill() Closes #2625 Closes #10016
2014-02-23Remove all ToStr impls, add Show implsAlex Crichton-54/+15
This commit changes the ToStr trait to: impl<T: fmt::Show> ToStr for T { fn to_str(&self) -> ~str { format!("{}", *self) } } The ToStr trait has been on the chopping block for quite awhile now, and this is the final nail in its coffin. The trait and the corresponding method are not being removed as part of this commit, but rather any implementations of the `ToStr` trait are being forbidden because of the generic impl. The new way to get the `to_str()` method to work is to implement `fmt::Show`. Formatting into a `&mut Writer` (as `format!` does) is much more efficient than `ToStr` when building up large strings. The `ToStr` trait forces many intermediate allocations to be made while the `fmt::Show` trait allows incremental buildup in the same heap allocated buffer. Additionally, the `fmt::Show` trait is much more extensible in terms of interoperation with other `Writer` instances and in more situations. By design the `ToStr` trait requires at least one allocation whereas the `fmt::Show` trait does not require any allocations. Closes #8242 Closes #9806
2014-02-23Merge remote-tracking branch 'brson/iodoc'Brian Anderson-126/+41
2014-02-23Closes #12386. Removed 'pub mod' doc-comments in std::io's mod.rs file. ↵zslayton-19/+9
Added summary doc-comments to test.rs, util.rs and stdio.rs.
2014-02-24Transition to new `Hash`, removing IterBytes and std::to_bytes.Huon Wilson-15/+3
2014-02-23Move std::{trie, hashmap} to libcollectionsAlex Crichton-8/+13
These two containers are indeed collections, so their place is in libcollections, not in libstd. There will always be a hash map as part of the standard distribution of Rust, but by moving it out of the standard library it makes libstd that much more portable to more platforms and environments. This conveniently also removes the stuttering of 'std::hashmap::HashMap', although 'collections::HashMap' is only one character shorter.
2014-02-22std: Remove some nonsense from old std::io docsBrian Anderson-126/+41
Most of this stuff is irrelevant implementation notes from last year. This trims out the stuff that isn't appropriate for user-facing docs.
2014-02-21auto merge of #12422 : alexcrichton/rust/buffered-default, r=brsonbors-10/+20
One of the most common ways to use the stdin stream is to read it line by line for a small program. In order to facilitate this common usage pattern, this commit changes the stdin() function to return a BufferedReader by default. A new `stdin_raw()` method was added to get access to the raw unbuffered stream. I have not changed the stdout or stderr methods because they are currently unable to flush in their destructor, but #12403 should have just fixed that.
2014-02-22Reduce reliance on `to_str_radix`Brendan Zabarauskas-2/+2
This is in preparation to remove the implementations of ToStrRadix in integers, and to remove the associated logic from `std::num::strconv`. The parts that still need to be liberated are: - `std::fmt::Formatter::runplural` - `num::{bigint, complex, rational}`
2014-02-20Mass rename if_ok! to try!Alex Crichton-27/+27
This "bubble up an error" macro was originally named if_ok! in order to get it landed, but after the fact it was discovered that this name is not exactly desirable. The name `if_ok!` isn't immediately clear that is has much to do with error handling, and it doesn't look fantastic in all contexts (if if_ok!(...) {}). In general, the agreed opinion about `if_ok!` is that is came in as subpar. The name `try!` is more invocative of error handling, it's shorter by 2 letters, and it looks fitting in almost all circumstances. One concern about the word `try!` is that it's too invocative of exceptions, but the belief is that this will be overcome with documentation and examples. Close #12037
2014-02-20Return a buffered stdin by default.Alex Crichton-10/+20
One of the most common ways to use the stdin stream is to read it line by line for a small program. In order to facilitate this common usage pattern, this commit changes the stdin() function to return a BufferedReader by default. A new `stdin_raw()` method was added to get access to the raw unbuffered stream. I have not changed the stdout or stderr methods because they are currently unable to flush in their destructor, but #12403 should have just fixed that.
2014-02-20move extra::test to libtestLiigo Zhuang-2/+4
2014-02-18auto merge of #12345 : huonw/rust/speeling, r=cmrbors-1/+1
2014-02-18Spellcheck library docs.Huon Wilson-1/+1
2014-02-16Implement named pipes for windows, touch up unixAlex Crichton-42/+61
* Implementation of pipe_win32 filled out for libnative * Reorganize pipes to be clone-able * Fix a few file descriptor leaks on error * Factor out some common code into shared functions * Make use of the if_ok!() macro for less indentation Closes #11201
2014-02-16Allow configuration of uid/gid/detach on processesAlex Crichton-23/+106
This just copies the libuv implementation for libnative which seems reasonable enough (uid/gid fail on windows). Closes #12082
2014-02-15auto merge of #12299 : sfackler/rust/limit-return, r=alexcrichtonbors-2/+24
This is useful in contexts like this: ```rust let size = rdr.read_be_i32() as uint; let mut limit = LimitReader::new(rdr.by_ref(), size); let thing = read_a_thing(&mut limit); assert!(limit.limit() == 0); ```
2014-02-15auto merge of #12298 : alexcrichton/rust/rustdoc-testing, r=sfacklerbors-9/+21
It's too easy to forget the `rust` tag to test something. Closes #11698
2014-02-15Add a method to LimitReader to return the limitSteven Fackler-2/+24
This is useful in contexts like this: let size = rdr.read_be_i32() as uint; let mut limit = LimitReader::new(rdr.by_ref(), size); let thing = read_a_thing(&mut limit); assert!(limit.limit() == 0);
2014-02-15auto merge of #12282 : cmr/rust/cleanup-ptr, r=huonwbors-6/+4
2014-02-15std: clean up ptr a bitCorey Richardson-6/+4
2014-02-14Fix all code examplesAlex Crichton-9/+21