Fill out the remaining functionality in io::file

This adds bindings to the remaining functions provided by libuv, all of which
are useful operations on files which need to get exposed somehow.

Some highlights:

* Dropped `FileReader` and `FileWriter` and `FileStream` for one `File` type
* Moved all file-related methods to be static methods under `File`
* All directory related methods are still top-level functions
* Created `io::FilePermission` types (backed by u32) that are what you'd expect
* Created `io::FileType` and refactored `FileStat` to use FileType and
  FilePermission
* Removed the expanding matrix of `FileMode` operations. The mode of reading a
  file will not have the O_CREAT flag, but a write mode will always have the
  O_CREAT flag.

Closes #10130
Closes #10131
Closes #10121
This commit is contained in:
Alex Crichton 2013-10-29 23:31:07 -07:00
parent 9c1851019f
commit f19d083362
38 changed files with 1381 additions and 1030 deletions

View file

@ -20,8 +20,7 @@ use parse::token::{get_ident_interner};
use print::pprust;
use std::rt::io;
use std::rt::io::Reader;
use std::rt::io::file;
use std::rt::io::File;
use std::str;
// These macros all relate to the file system; they either return
@ -92,7 +91,7 @@ pub fn expand_include_str(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
-> base::MacResult {
let file = get_single_str_from_tts(cx, sp, tts, "include_str!");
let file = res_rel_file(cx, sp, &Path::new(file));
let bytes = match io::result(|| file::open(&file).read_to_end()) {
let bytes = match io::result(|| File::open(&file).read_to_end()) {
Err(e) => {
cx.span_fatal(sp, format!("couldn't read {}: {}",
file.display(), e.desc));
@ -114,7 +113,7 @@ pub fn expand_include_bin(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
let file = get_single_str_from_tts(cx, sp, tts, "include_bin!");
let file = res_rel_file(cx, sp, &Path::new(file));
match io::result(|| file::open(&file).read_to_end()) {
match io::result(|| File::open(&file).read_to_end()) {
Err(e) => {
cx.span_fatal(sp, format!("couldn't read {}: {}",
file.display(), e.desc));