forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unfortunately, the main test for this is ignored due to rust-lang#7071. Closes rust-lang#5682
- Loading branch information
1 parent
efd1438
commit 211d70e
Showing
3 changed files
with
87 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,11 +22,36 @@ use core::iterator::IteratorUtil; | |
use messages::*; | ||
use package_id::*; | ||
|
||
fn push_if_exists(vec: &mut ~[Path], p: &Path) { | ||
let maybe_dir = p.push(".rust"); | ||
if os::path_exists(&maybe_dir) { | ||
vec.push(maybe_dir); | ||
} | ||
} | ||
|
||
#[cfg(windows)] | ||
static path_entry_separator: &'static str = ";"; | ||
#[cfg(not(windows))] | ||
static path_entry_separator: &'static str = ":"; | ||
|
||
/// Returns the value of RUST_PATH, as a list | ||
/// of Paths. In general this should be read from the | ||
/// environment; for now, it's hard-wired to just be "." | ||
/// of Paths. Includes default entries for, if they exist: | ||
/// $HOME/.rust | ||
/// DIR/.rust for any DIR that's the current working directory | ||
/// or an ancestor of it | ||
pub fn rust_path() -> ~[Path] { | ||
~[Path(".")] | ||
let env_path: ~str = os::getenv("RUST_PATH").get_or_default(~""); | ||
let env_path_components: ~[&str] = env_path.split_str_iter(path_entry_separator).collect(); | ||
let mut env_rust_path: ~[Path] = env_path_components.map(|&s| Path(s)); | ||
let cwd = os::getcwd(); | ||
// now add in default entries | ||
env_rust_path.push(copy cwd); | ||
do cwd.each_parent() |p| { push_if_exists(&mut env_rust_path, p) }; | ||
let h = os::homedir(); | ||
for h.iter().advance |h| { | ||
push_if_exists(&mut env_rust_path, h); | ||
} | ||
env_rust_path | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
catamorphism
Author
Owner
|
||
} | ||
|
||
pub static u_rwx: i32 = (S_IRUSR | S_IWUSR | S_IXUSR) as i32; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 comment
on commit 211d70e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r+
That's a handsome function. Good use of iterators and other library features. Tasteful type annotations.