diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-06-07 21:38:25 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-06-07 22:28:00 -0700 |
| commit | 95b9d538b8bda04e222c95d478b97c19d77bb5c6 (patch) | |
| tree | 819961fab6287b7b174879c1bddff7159487bdc2 /src/libcore/path.rs | |
| parent | 7ef825bb607c4e934c92bd0b73ecbc4c24f3286b (diff) | |
| download | rust-95b9d538b8bda04e222c95d478b97c19d77bb5c6.tar.gz rust-95b9d538b8bda04e222c95d478b97c19d77bb5c6.zip | |
Use #[cfg(unix)] and #[cfg(windows)] everywhere
Diffstat (limited to 'src/libcore/path.rs')
| -rw-r--r-- | src/libcore/path.rs | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/libcore/path.rs b/src/libcore/path.rs index a771f2b9928..2e62b73063d 100644 --- a/src/libcore/path.rs +++ b/src/libcore/path.rs @@ -16,9 +16,7 @@ export normalize; #[doc = "A path or fragment of a filesystem path"] type path = str; -#[cfg(target_os = "macos")] -#[cfg(target_os = "freebsd")] -#[cfg(target_os = "linux")] +#[cfg(unix)] mod consts { #[doc = " The primary path seperator character for the platform @@ -34,7 +32,7 @@ mod consts { const alt_path_sep: char = '/'; } -#[cfg(target_os = "win32")] +#[cfg(windows)] mod consts { const path_sep: char = '/'; const alt_path_sep: char = '\\'; @@ -46,14 +44,12 @@ Indicates whether a path is absolute. A path is considered absolute if it begins at the filesystem root (\"/\") or, on Windows, begins with a drive letter. "] -#[cfg(target_os = "macos")] -#[cfg(target_os = "freebsd")] -#[cfg(target_os = "linux")] +#[cfg(unix)] fn path_is_absolute(p: path) -> bool { str::char_at(p, 0u) == '/' } -#[cfg(target_os = "win32")] +#[cfg(windows)] fn path_is_absolute(p: str) -> bool { ret str::char_at(p, 0u) == '/' || str::char_at(p, 1u) == ':' @@ -271,9 +267,7 @@ fn normalize(p: path) -> path { ret t; } - #[cfg(target_os = "linux")] - #[cfg(target_os = "macos")] - #[cfg(target_os = "freebsd")] + #[cfg(unix)] fn reabsolute(orig: path, n: path) -> path { if path_is_absolute(orig) { path_sep() + n @@ -282,7 +276,7 @@ fn normalize(p: path) -> path { } } - #[cfg(target_os = "win32")] + #[cfg(windows)] fn reabsolute(orig: path, newp: path) -> path { if path_is_absolute(orig) && orig[0] == consts::path_sep as u8 { str::from_char(consts::path_sep) + newp @@ -427,7 +421,7 @@ mod tests { } #[test] - #[cfg(target_os = "win32")] + #[cfg(windows)] fn normalize12() { let actual = normalize("C:/whatever"); let expected = "C:/whatever"; @@ -436,7 +430,7 @@ mod tests { } #[test] - #[cfg(target_os = "win32")] + #[cfg(windows)] fn path_is_absolute_win32() { assert path_is_absolute("C:/whatever"); } |
