diff options
-rw-r--r-- | components/gfx/lib.rs | 2 | ||||
-rw-r--r-- | components/gfx/platform/freetype/font_template.rs | 10 | ||||
-rw-r--r-- | components/layout/layout_debug.rs | 5 | ||||
-rw-r--r-- | components/layout/lib.rs | 2 | ||||
-rw-r--r-- | components/net/resource_task.rs | 10 | ||||
-rw-r--r-- | components/util/memory.rs | 28 |
6 files changed, 32 insertions, 25 deletions
diff --git a/components/gfx/lib.rs b/components/gfx/lib.rs index 2bd53bd699b..62f72722b9c 100644 --- a/components/gfx/lib.rs +++ b/components/gfx/lib.rs @@ -7,7 +7,7 @@ #![feature(collections)] #![feature(core)] #![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))] #![feature(plugin)] #![feature(rustc_private)] diff --git a/components/gfx/platform/freetype/font_template.rs b/components/gfx/platform/freetype/font_template.rs index b41a5f0d7e6..176cd0f397b 100644 --- a/components/gfx/platform/freetype/font_template.rs +++ b/components/gfx/platform/freetype/font_template.rs @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use std::borrow::ToOwned; -use std::old_io as io; -use std::old_io::File; +use std::fs::File; +use std::io::Read; /// Platform specific font representation for Linux. /// The identifier is an absolute path, and the bytes @@ -23,8 +23,10 @@ impl FontTemplateData { }, None => { // TODO: Handle file load failure! - let mut file = File::open_mode(&Path::new(identifier), io::Open, io::Read).unwrap(); - file.read_to_end().unwrap() + let mut file = File::open(identifier).unwrap(); + let mut buffer = vec![]; + file.read_to_end(&mut buffer).unwrap(); + buffer }, }; diff --git a/components/layout/layout_debug.rs b/components/layout/layout_debug.rs index ed73a1c693e..ecc42408982 100644 --- a/components/layout/layout_debug.rs +++ b/components/layout/layout_debug.rs @@ -13,7 +13,8 @@ use rustc_serialize::json; use std::borrow::ToOwned; 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}; 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 path = Path::new("layout_trace.json"); let mut file = File::create(&path).unwrap(); - file.write_str(result.as_slice()).unwrap(); + file.write_all(result.as_bytes()).unwrap(); } diff --git a/components/layout/lib.rs b/components/layout/lib.rs index 0beebba4c51..6e3adda5807 100644 --- a/components/layout/lib.rs +++ b/components/layout/lib.rs @@ -7,7 +7,7 @@ #![feature(collections)] #![feature(core)] #![feature(int_uint)] -#![feature(old_io)] +#![feature(io)] #![feature(old_path)] #![feature(plugin)] #![feature(rustc_private)] diff --git a/components/net/resource_task.rs b/components/net/resource_task.rs index 8208aef00a9..badc794bda7 100644 --- a/components/net/resource_task.rs +++ b/components/net/resource_task.rs @@ -26,7 +26,8 @@ use std::borrow::{ToOwned, IntoCow}; use std::boxed; use std::collections::HashMap; 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::thunk::Invoke; @@ -45,12 +46,13 @@ pub fn global_init() { }; let mut file = match File::open(&path) { - Ok(f) => BufferedReader::new(f), + Ok(f) => BufReader::new(f), Err(_) => return, }; - let lines = match file.read_to_string() { - Ok(lines) => lines, + let mut lines = String::new(); + match file.read_to_string(&mut lines) { + Ok(()) => (), Err(_) => return, }; diff --git a/components/util/memory.rs b/components/util/memory.rs index 487d22aab86..54fd627d5d7 100644 --- a/components/util/memory.rs +++ b/components/util/memory.rs @@ -12,8 +12,6 @@ use std::ffi::CString; #[cfg(target_os = "linux")] use std::iter::AdditiveIterator; use std::old_io::timer::sleep; -#[cfg(target_os="linux")] -use std::old_io::File; use std::mem::{size_of, transmute}; use std::ptr::null_mut; use std::sync::Arc; @@ -489,15 +487,15 @@ macro_rules! option_try( #[cfg(target_os="linux")] fn get_proc_self_statm_field(field: usize) -> Option<u64> { - let mut f = File::open(&Path::new("/proc/self/statm")); - match f.read_to_string() { - Ok(contents) => { - let s = option_try!(contents.as_slice().words().nth(field)); - let npages = option_try!(s.parse::<u64>().ok()); - Some(npages * (::std::env::page_size() as u64)) - } - Err(_) => None - } + use std::fs::File; + use std::io::Read; + + let mut f = option_try!(File::open("/proc/self/statm").ok()); + let mut contents = String::new(); + option_try!(f.read_to_string(&mut contents).ok()); + let s = option_try!(contents.words().nth(field)); + let npages = option_try!(s.parse::<u64>().ok()); + Some(npages * (::std::env::page_size() as u64)) } #[cfg(target_os="linux")] @@ -535,6 +533,8 @@ fn get_resident_segments() -> Vec<(String, u64)> { use regex::Regex; use std::collections::HashMap; 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 // in /proc/<pid>/maps: @@ -548,8 +548,10 @@ fn get_resident_segments() -> Vec<(String, u64)> { // // Rss: 132 kB - let path = Path::new("/proc/self/smaps"); - let mut f = ::std::old_io::BufferedReader::new(File::open(&path)); + let f = match File::open("/proc/self/smaps") { + Ok(f) => BufReader::new(f), + Err(_) => return vec![], + }; let seg_re = Regex::new( r"^[:xdigit:]+-[:xdigit:]+ (....) [:xdigit:]+ [:xdigit:]+:[:xdigit:]+ \d+ +(.*)").unwrap(); |