mirror of
https://github.com/servo/servo.git
synced 2025-07-02 21:13:39 +01:00
auto merge of #5297 : Ms2ger/servo/fs, r=SimonSapin
This commit is contained in:
commit
ec60f29203
6 changed files with 32 additions and 25 deletions
|
@ -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)]
|
||||
|
|
|
@ -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
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#![feature(collections)]
|
||||
#![feature(core)]
|
||||
#![feature(int_uint)]
|
||||
#![feature(old_io)]
|
||||
#![feature(io)]
|
||||
#![feature(old_path)]
|
||||
#![feature(plugin)]
|
||||
#![feature(rustc_private)]
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue