mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-19 12:05:08 +00:00
auto merge of #9366 : olsonjeffery/rust/file_io_doc_cleanup, r=brson
fixing spew that @achricto was nice enough to point out to me
This commit is contained in:
commit
635a381896
@ -32,8 +32,7 @@ free function counterparts.
|
||||
use prelude::*;
|
||||
use super::support::PathLike;
|
||||
use super::{Reader, Writer, Seek};
|
||||
use super::{SeekStyle,SeekSet, SeekCur, SeekEnd,
|
||||
Open, Read, Write, Create, ReadWrite};
|
||||
use super::{SeekStyle, Read, Write};
|
||||
use rt::rtio::{RtioFileStream, IoFactory, IoFactoryObject};
|
||||
use rt::io::{io_error, read_error, EndOfFile,
|
||||
FileMode, FileAccess, FileStat, IoError,
|
||||
@ -42,7 +41,6 @@ use rt::io::{io_error, read_error, EndOfFile,
|
||||
use rt::local::Local;
|
||||
use option::{Some, None};
|
||||
use path::Path;
|
||||
use super::super::test::*;
|
||||
|
||||
/// Open a file for reading/writing, as indicated by `path`.
|
||||
///
|
||||
@ -479,6 +477,7 @@ pub trait FileSystemInfo {
|
||||
///
|
||||
/// * Check if a file exists, reading from it if so
|
||||
///
|
||||
/// ~~~{.rust}
|
||||
/// use std;
|
||||
/// use std::path::Path;
|
||||
/// use std::rt::io::file::{FileInfo, FileReader};
|
||||
@ -490,14 +489,17 @@ pub trait FileSystemInfo {
|
||||
/// reader.read(mem);
|
||||
/// // ...
|
||||
/// }
|
||||
/// ~~~
|
||||
///
|
||||
/// * Is the given path a file?
|
||||
///
|
||||
/// ~~~{.rust}
|
||||
/// let f = get_file_path_from_wherever();
|
||||
/// match f.is_file() {
|
||||
/// true => doing_something_with_a_file(f),
|
||||
/// _ => {}
|
||||
/// }
|
||||
/// ~~~
|
||||
pub trait FileInfo : FileSystemInfo {
|
||||
/// Whether the underlying implemention (be it a file path,
|
||||
/// or something else) points at a "regular file" on the FS. Will return
|
||||
@ -572,6 +574,7 @@ impl FileInfo for Path { }
|
||||
///
|
||||
/// * Check if a directory exists, `mkdir`'ing it if not
|
||||
///
|
||||
/// ~~~{.rust}
|
||||
/// use std;
|
||||
/// use std::path::Path;
|
||||
/// use std::rt::io::file::{DirectoryInfo};
|
||||
@ -580,9 +583,11 @@ impl FileInfo for Path { }
|
||||
/// if !dir.exists() {
|
||||
/// dir.mkdir();
|
||||
/// }
|
||||
/// ~~~
|
||||
///
|
||||
/// * Is the given path a directory? If so, iterate on its contents
|
||||
///
|
||||
/// ~~~{.rust}
|
||||
/// fn visit_dirs(dir: &Path, cb: &fn(&Path)) {
|
||||
/// if dir.is_dir() {
|
||||
/// let contents = dir.readdir();
|
||||
@ -593,6 +598,7 @@ impl FileInfo for Path { }
|
||||
/// }
|
||||
/// else { fail!("nope"); }
|
||||
/// }
|
||||
/// ~~~
|
||||
trait DirectoryInfo : FileSystemInfo {
|
||||
/// Whether the underlying implemention (be it a file path,
|
||||
/// or something else) is pointing at a directory in the underlying FS.
|
||||
@ -678,7 +684,17 @@ trait DirectoryInfo : FileSystemInfo {
|
||||
/// `DirectoryInfo` impl for `path::Path`
|
||||
impl DirectoryInfo for Path { }
|
||||
|
||||
fn file_test_smoke_test_impl() {
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::super::{SeekSet, SeekCur, SeekEnd,
|
||||
io_error, Read, Create, Open, ReadWrite};
|
||||
use super::super::super::test::*;
|
||||
use option::{Some, None};
|
||||
use path::Path;
|
||||
use super::*;
|
||||
use iter::range;
|
||||
#[test]
|
||||
fn file_test_io_smoke_test() {
|
||||
do run_in_mt_newsched_task {
|
||||
let message = "it's alright. have a good time";
|
||||
let filename = &Path("./tmp/file_rt_io_file_test.txt");
|
||||
@ -701,11 +717,7 @@ fn file_test_smoke_test_impl() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn file_test_io_smoke_test() {
|
||||
file_test_smoke_test_impl();
|
||||
}
|
||||
|
||||
fn file_test_invalid_path_opened_without_create_should_raise_condition_impl() {
|
||||
fn file_test_io_invalid_path_opened_without_create_should_raise_condition() {
|
||||
do run_in_mt_newsched_task {
|
||||
let filename = &Path("./tmp/file_that_does_not_exist.txt");
|
||||
let mut called = false;
|
||||
@ -718,12 +730,9 @@ fn file_test_invalid_path_opened_without_create_should_raise_condition_impl() {
|
||||
assert!(called);
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn file_test_io_invalid_path_opened_without_create_should_raise_condition() {
|
||||
file_test_invalid_path_opened_without_create_should_raise_condition_impl();
|
||||
}
|
||||
|
||||
fn file_test_unlinking_invalid_path_should_raise_condition_impl() {
|
||||
#[test]
|
||||
fn file_test_iounlinking_invalid_path_should_raise_condition() {
|
||||
do run_in_mt_newsched_task {
|
||||
let filename = &Path("./tmp/file_another_file_that_does_not_exist.txt");
|
||||
let mut called = false;
|
||||
@ -735,12 +744,9 @@ fn file_test_unlinking_invalid_path_should_raise_condition_impl() {
|
||||
assert!(called);
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn file_test_iounlinking_invalid_path_should_raise_condition() {
|
||||
file_test_unlinking_invalid_path_should_raise_condition_impl();
|
||||
}
|
||||
|
||||
fn file_test_io_non_positional_read_impl() {
|
||||
#[test]
|
||||
fn file_test_io_non_positional_read() {
|
||||
do run_in_mt_newsched_task {
|
||||
use str;
|
||||
let message = "ten-four";
|
||||
@ -768,11 +774,7 @@ fn file_test_io_non_positional_read_impl() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn file_test_io_non_positional_read() {
|
||||
file_test_io_non_positional_read_impl();
|
||||
}
|
||||
|
||||
fn file_test_io_seeking_impl() {
|
||||
fn file_test_io_seek_and_tell_smoke_test() {
|
||||
do run_in_mt_newsched_task {
|
||||
use str;
|
||||
let message = "ten-four";
|
||||
@ -801,11 +803,7 @@ fn file_test_io_seeking_impl() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn file_test_io_seek_and_tell_smoke_test() {
|
||||
file_test_io_seeking_impl();
|
||||
}
|
||||
|
||||
fn file_test_io_seek_and_write_impl() {
|
||||
fn file_test_io_seek_and_write() {
|
||||
do run_in_mt_newsched_task {
|
||||
use str;
|
||||
let initial_msg = "food-is-yummy";
|
||||
@ -831,11 +829,7 @@ fn file_test_io_seek_and_write_impl() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn file_test_io_seek_and_write() {
|
||||
file_test_io_seek_and_write_impl();
|
||||
}
|
||||
|
||||
fn file_test_io_seek_shakedown_impl() {
|
||||
fn file_test_io_seek_shakedown() {
|
||||
do run_in_mt_newsched_task {
|
||||
use str; // 01234567890123
|
||||
let initial_msg = "qwer-asdf-zxcv";
|
||||
@ -870,11 +864,6 @@ fn file_test_io_seek_shakedown_impl() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn file_test_io_seek_shakedown() {
|
||||
file_test_io_seek_shakedown_impl();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn file_test_stat_is_correct_on_is_file() {
|
||||
do run_in_mt_newsched_task {
|
||||
@ -982,3 +971,4 @@ fn file_test_directoryinfo_readdir() {
|
||||
dir.rmdir();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user