Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/librustpkg/conditions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@

pub use std::path::Path;
pub use package_id::PkgId;
pub use std::libc;
pub use std::libc::stat;
pub use std::rt::io::FileStat;

condition! {
pub bad_path: (Path, ~str) -> Path;
}

condition! {
pub bad_stat: (Path, ~str) -> stat;
pub bad_stat: (Path, ~str) -> FileStat;
}

condition! {
Expand Down
4 changes: 2 additions & 2 deletions src/librustpkg/util.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand Down Expand Up @@ -609,7 +609,7 @@ fn debug_flags() -> ~[~str] { ~[] }
/// Returns the last-modified date as an Option
pub fn datestamp(p: &Path) -> Option<libc::time_t> {
debug!("Scrutinizing datestamp for {} - does it exist? {:?}", p.display(), os::path_exists(p));
let out = p.stat().map(|stat| stat.st_mtime);
let out = p.stat().map(|stat| stat.modified);
debug!("Date = {:?}", out);
out.map(|t| { t as libc::time_t })
}
Expand Down
14 changes: 7 additions & 7 deletions src/librustpkg/workcache_support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ pub fn digest_file_with_date(path: &Path) -> ~str {
use conditions::bad_path::cond;
use cond1 = conditions::bad_stat::cond;

let mut sha = ~Sha1::new();
let s = io::read_whole_file_str(path);
match s {
Ok(s) => {
(*sha).input_str(s);
let mut sha = Sha1::new();
sha.input_str(s);
let st = match path.stat() {
Some(st) => st,
None => cond1.raise((path.clone(), format!("Couldn't get file access time")))
};
(*sha).input_str(st.st_mtime.to_str());
(*sha).result_str()
sha.input_str(st.modified.to_str());
sha.result_str()
}
Err(e) => {
let path = cond.raise((path.clone(), format!("Couldn't read file: {}", e)));
Expand All @@ -43,13 +43,13 @@ pub fn digest_file_with_date(path: &Path) -> ~str {
pub fn digest_only_date(path: &Path) -> ~str {
use cond = conditions::bad_stat::cond;

let mut sha = ~Sha1::new();
let mut sha = Sha1::new();
let st = match path.stat() {
Some(st) => st,
None => cond.raise((path.clone(), format!("Couldn't get file access time")))
};
(*sha).input_str(st.st_mtime.to_str());
(*sha).result_str()
sha.input_str(st.modified.to_str());
sha.result_str()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sneaky sneaky

}

/// Adds multiple discovered outputs
Expand Down
224 changes: 1 addition & 223 deletions src/libstd/path/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -688,228 +688,6 @@ fn from_utf8_with_replacement(mut v: &[u8]) -> ~str {
}
s
}

// FIXME (#9537): libc::stat should derive Default
#[cfg(target_os = "linux")]
#[cfg(target_os = "android")]
mod stat {
#[allow(missing_doc)];

#[cfg(target_arch = "x86")]
pub mod arch {
use libc;

pub fn default_stat() -> libc::stat {
libc::stat {
st_dev: 0,
__pad1: 0,
st_ino: 0,
st_mode: 0,
st_nlink: 0,
st_uid: 0,
st_gid: 0,
st_rdev: 0,
__pad2: 0,
st_size: 0,
st_blksize: 0,
st_blocks: 0,
st_atime: 0,
st_atime_nsec: 0,
st_mtime: 0,
st_mtime_nsec: 0,
st_ctime: 0,
st_ctime_nsec: 0,
__unused4: 0,
__unused5: 0,
}
}
}

#[cfg(target_arch = "arm")]
pub mod arch {
use libc;

pub fn default_stat() -> libc::stat {
libc::stat {
st_dev: 0,
__pad0: [0, ..4],
__st_ino: 0,
st_mode: 0,
st_nlink: 0,
st_uid: 0,
st_gid: 0,
st_rdev: 0,
__pad3: [0, ..4],
st_size: 0,
st_blksize: 0,
st_blocks: 0,
st_atime: 0,
st_atime_nsec: 0,
st_mtime: 0,
st_mtime_nsec: 0,
st_ctime: 0,
st_ctime_nsec: 0,
st_ino: 0
}
}
}

#[cfg(target_arch = "mips")]
pub mod arch {
use libc;

pub fn default_stat() -> libc::stat {
libc::stat {
st_dev: 0,
st_pad1: [0, ..3],
st_ino: 0,
st_mode: 0,
st_nlink: 0,
st_uid: 0,
st_gid: 0,
st_rdev: 0,
st_pad2: [0, ..2],
st_size: 0,
st_pad3: 0,
st_atime: 0,
st_atime_nsec: 0,
st_mtime: 0,
st_mtime_nsec: 0,
st_ctime: 0,
st_ctime_nsec: 0,
st_blksize: 0,
st_blocks: 0,
st_pad5: [0, ..14],
}
}
}

#[cfg(target_arch = "x86_64")]
pub mod arch {
use libc;

pub fn default_stat() -> libc::stat {
libc::stat {
st_dev: 0,
st_ino: 0,
st_nlink: 0,
st_mode: 0,
st_uid: 0,
st_gid: 0,
__pad0: 0,
st_rdev: 0,
st_size: 0,
st_blksize: 0,
st_blocks: 0,
st_atime: 0,
st_atime_nsec: 0,
st_mtime: 0,
st_mtime_nsec: 0,
st_ctime: 0,
st_ctime_nsec: 0,
__unused: [0, 0, 0],
}
}
}
}

#[cfg(target_os = "freebsd")]
mod stat {
#[allow(missing_doc)];

#[cfg(target_arch = "x86_64")]
pub mod arch {
use libc;

pub fn default_stat() -> libc::stat {
libc::stat {
st_dev: 0,
st_ino: 0,
st_mode: 0,
st_nlink: 0,
st_uid: 0,
st_gid: 0,
st_rdev: 0,
st_atime: 0,
st_atime_nsec: 0,
st_mtime: 0,
st_mtime_nsec: 0,
st_ctime: 0,
st_ctime_nsec: 0,
st_size: 0,
st_blocks: 0,
st_blksize: 0,
st_flags: 0,
st_gen: 0,
st_lspare: 0,
st_birthtime: 0,
st_birthtime_nsec: 0,
__unused: [0, 0],
}
}
}
}

#[cfg(target_os = "macos")]
mod stat {
#[allow(missing_doc)];

pub mod arch {
use libc;

pub fn default_stat() -> libc::stat {
libc::stat {
st_dev: 0,
st_mode: 0,
st_nlink: 0,
st_ino: 0,
st_uid: 0,
st_gid: 0,
st_rdev: 0,
st_atime: 0,
st_atime_nsec: 0,
st_mtime: 0,
st_mtime_nsec: 0,
st_ctime: 0,
st_ctime_nsec: 0,
st_birthtime: 0,
st_birthtime_nsec: 0,
st_size: 0,
st_blocks: 0,
st_blksize: 0,
st_flags: 0,
st_gen: 0,
st_lspare: 0,
st_qspare: [0, 0],
}
}
}
}

#[cfg(target_os = "win32")]
mod stat {
#[allow(missing_doc)];

pub mod arch {
use libc;
pub fn default_stat() -> libc::stat {
libc::stat {
st_dev: 0,
st_ino: 0,
st_mode: 0,
st_nlink: 0,
st_uid: 0,
st_gid: 0,
st_rdev: 0,
st_size: 0,
st_atime: 0,
st_mtime: 0,
st_ctime: 0,
}
}
}
}

#[cfg(test)]
mod tests {
use super::{GenericPath, PosixPath, WindowsPath};
Expand All @@ -921,7 +699,7 @@ mod tests {
let path: PosixPath = PosixPath::new(input.to_c_str());
assert_eq!(path.as_vec(), input.as_bytes());

let input = "\\foo\\bar\\baz";
let input = r"\foo\bar\baz";
let path: WindowsPath = WindowsPath::new(input.to_c_str());
assert_eq!(path.as_str().unwrap(), input.as_slice());
}
Expand Down
Loading