Skip to content

Commit fa88306

Browse files
unknownEric Holk
authored andcommitted
---
yaml --- r: 3218 b: refs/heads/master c: 8c6354c h: refs/heads/master v: v3
1 parent 4caf15f commit fa88306

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 7c57b8baf5e71e114da226293f15cd96d5baacac
2+
refs/heads/master: 8c6354ceb905895c9f305716c66d5c7a8e4d0225

trunk/src/lib/fs.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

22
import os::getcwd;
3+
import os_fs;
4+
import str;
35

46
native "rust" mod rustrt {
57
fn rust_file_is_dir(str path) -> int;
@@ -58,13 +60,12 @@ fn list_dir(path p) -> vec[str] {
5860
ret full_paths;
5961
}
6062

61-
// FIXME: Windows absolute paths can start with \ for C:\ or
62-
// whatever... However, we're under MinGW32 so we have the same rules and
63-
// posix has.
6463
fn path_is_absolute(path p) -> bool {
65-
ret p.(0) == '/';
64+
ret os_fs::path_is_absolute(p);
6665
}
6766

67+
// FIXME: under Windows, we should prepend the current drive letter to paths
68+
// that start with a slash.
6869
fn make_absolute(path p) -> path {
6970
if(path_is_absolute(p)) {
7071
ret p;

trunk/src/lib/posix_fs.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ fn list_dir(str path) -> vec[str] {
3232

3333
}
3434

35+
fn path_is_absolute(str p) -> bool {
36+
ret str::char_at(p, 0u) == '/';
37+
}
38+
3539
const char path_sep = '/';
3640

3741
const char alt_path_sep = '/';

trunk/src/lib/win32_fs.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ native "rust" mod rustrt {
77

88
fn list_dir(str path) -> vec[str] { ret rustrt::rust_list_files(path + "*"); }
99

10+
fn path_is_absolute(str p) -> bool {
11+
ret str::char_at(p, 0u) == '/'
12+
|| (str::char_at(p, 1u) == ':' && str::char_at(p, 2u) == '\\');
13+
}
14+
1015
/* FIXME: win32 path handling actually accepts '/' or '\' and has subtly
1116
* different semantics for each. Since we build on mingw, we are usually
1217
* dealing with /-separated paths. But the whole interface to splitting and

0 commit comments

Comments
 (0)