auto merge of #5297 : Ms2ger/servo/fs, r=SimonSapin

This commit is contained in:
bors-servo 2015-03-20 17:00:44 -06:00
commit ec60f29203
6 changed files with 32 additions and 25 deletions

View file

@ -7,7 +7,7 @@
#![feature(collections)] #![feature(collections)]
#![feature(core)] #![feature(core)]
#![feature(int_uint)] #![feature(int_uint)]
#![cfg_attr(any(target_os="linux", target_os = "android"), feature(old_io))] #![cfg_attr(any(target_os="linux", target_os = "android"), feature(io))]
#![cfg_attr(any(target_os="linux", target_os = "android"), feature(old_path))] #![cfg_attr(any(target_os="linux", target_os = "android"), feature(old_path))]
#![feature(plugin)] #![feature(plugin)]
#![feature(rustc_private)] #![feature(rustc_private)]

View file

@ -3,8 +3,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::borrow::ToOwned; use std::borrow::ToOwned;
use std::old_io as io; use std::fs::File;
use std::old_io::File; use std::io::Read;
/// Platform specific font representation for Linux. /// Platform specific font representation for Linux.
/// The identifier is an absolute path, and the bytes /// The identifier is an absolute path, and the bytes
@ -23,8 +23,10 @@ impl FontTemplateData {
}, },
None => { None => {
// TODO: Handle file load failure! // TODO: Handle file load failure!
let mut file = File::open_mode(&Path::new(identifier), io::Open, io::Read).unwrap(); let mut file = File::open(identifier).unwrap();
file.read_to_end().unwrap() let mut buffer = vec![];
file.read_to_end(&mut buffer).unwrap();
buffer
}, },
}; };

View file

@ -13,7 +13,8 @@ use rustc_serialize::json;
use std::borrow::ToOwned; use std::borrow::ToOwned;
use std::cell::RefCell; use std::cell::RefCell;
use std::old_io::File; use std::io::Write;
use std::fs::File;
use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
thread_local!(static STATE_KEY: RefCell<Option<State>> = RefCell::new(None)); thread_local!(static STATE_KEY: RefCell<Option<State>> = RefCell::new(None));
@ -127,5 +128,5 @@ pub fn end_trace() {
let result = json::encode(&root_scope).unwrap(); let result = json::encode(&root_scope).unwrap();
let path = Path::new("layout_trace.json"); let path = Path::new("layout_trace.json");
let mut file = File::create(&path).unwrap(); let mut file = File::create(&path).unwrap();
file.write_str(result.as_slice()).unwrap(); file.write_all(result.as_bytes()).unwrap();
} }

View file

@ -7,7 +7,7 @@
#![feature(collections)] #![feature(collections)]
#![feature(core)] #![feature(core)]
#![feature(int_uint)] #![feature(int_uint)]
#![feature(old_io)] #![feature(io)]
#![feature(old_path)] #![feature(old_path)]
#![feature(plugin)] #![feature(plugin)]
#![feature(rustc_private)] #![feature(rustc_private)]

View file

@ -26,7 +26,8 @@ use std::borrow::{ToOwned, IntoCow};
use std::boxed; use std::boxed;
use std::collections::HashMap; use std::collections::HashMap;
use std::env; use std::env;
use std::old_io::{BufferedReader, File}; use std::fs::File;
use std::io::{BufReader, Read};
use std::sync::mpsc::{channel, Receiver, Sender}; use std::sync::mpsc::{channel, Receiver, Sender};
use std::thunk::Invoke; use std::thunk::Invoke;
@ -45,12 +46,13 @@ pub fn global_init() {
}; };
let mut file = match File::open(&path) { let mut file = match File::open(&path) {
Ok(f) => BufferedReader::new(f), Ok(f) => BufReader::new(f),
Err(_) => return, Err(_) => return,
}; };
let lines = match file.read_to_string() { let mut lines = String::new();
Ok(lines) => lines, match file.read_to_string(&mut lines) {
Ok(()) => (),
Err(_) => return, Err(_) => return,
}; };

View file

@ -12,8 +12,6 @@ use std::ffi::CString;
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
use std::iter::AdditiveIterator; use std::iter::AdditiveIterator;
use std::old_io::timer::sleep; use std::old_io::timer::sleep;
#[cfg(target_os="linux")]
use std::old_io::File;
use std::mem::{size_of, transmute}; use std::mem::{size_of, transmute};
use std::ptr::null_mut; use std::ptr::null_mut;
use std::sync::Arc; use std::sync::Arc;
@ -489,15 +487,15 @@ macro_rules! option_try(
#[cfg(target_os="linux")] #[cfg(target_os="linux")]
fn get_proc_self_statm_field(field: usize) -> Option<u64> { fn get_proc_self_statm_field(field: usize) -> Option<u64> {
let mut f = File::open(&Path::new("/proc/self/statm")); use std::fs::File;
match f.read_to_string() { use std::io::Read;
Ok(contents) => {
let s = option_try!(contents.as_slice().words().nth(field)); let mut f = option_try!(File::open("/proc/self/statm").ok());
let npages = option_try!(s.parse::<u64>().ok()); let mut contents = String::new();
Some(npages * (::std::env::page_size() as u64)) option_try!(f.read_to_string(&mut contents).ok());
} let s = option_try!(contents.words().nth(field));
Err(_) => None let npages = option_try!(s.parse::<u64>().ok());
} Some(npages * (::std::env::page_size() as u64))
} }
#[cfg(target_os="linux")] #[cfg(target_os="linux")]
@ -535,6 +533,8 @@ fn get_resident_segments() -> Vec<(String, u64)> {
use regex::Regex; use regex::Regex;
use std::collections::HashMap; use std::collections::HashMap;
use std::collections::hash_map::Entry; use std::collections::hash_map::Entry;
use std::fs::File;
use std::io::{BufReader, BufReadExt};
// The first line of an entry in /proc/<pid>/smaps looks just like an entry // The first line of an entry in /proc/<pid>/smaps looks just like an entry
// in /proc/<pid>/maps: // in /proc/<pid>/maps:
@ -548,8 +548,10 @@ fn get_resident_segments() -> Vec<(String, u64)> {
// //
// Rss: 132 kB // Rss: 132 kB
let path = Path::new("/proc/self/smaps"); let f = match File::open("/proc/self/smaps") {
let mut f = ::std::old_io::BufferedReader::new(File::open(&path)); Ok(f) => BufReader::new(f),
Err(_) => return vec![],
};
let seg_re = Regex::new( let seg_re = Regex::new(
r"^[:xdigit:]+-[:xdigit:]+ (....) [:xdigit:]+ [:xdigit:]+:[:xdigit:]+ \d+ +(.*)").unwrap(); r"^[:xdigit:]+-[:xdigit:]+ (....) [:xdigit:]+ [:xdigit:]+:[:xdigit:]+ \d+ +(.*)").unwrap();