File tree Expand file tree Collapse file tree 7 files changed +40
-14
lines changed Expand file tree Collapse file tree 7 files changed +40
-14
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: b11268780ed7961c710d6a66665b82a2e5019a08
2
+ refs/heads/master: 89e880d613bc797b3867f91cd7f676c9b4737397
Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ fn rest(s: str, start: uint) -> str {
112
112
}
113
113
114
114
fn need_dir ( s : str ) {
115
- if fs:: file_is_dir ( s) { ret; }
115
+ if fs:: path_is_dir ( s) { ret; }
116
116
if !fs:: make_dir ( s, 0x1c0i32 ) {
117
117
fail #fmt[ "can't make_dir %s" , s] ;
118
118
}
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ fn contains(haystack: str, needle: str) -> bool {
23
23
fn find_rust_files ( & files: [ str ] , path : str ) {
24
24
if str:: ends_with ( path, ".rs" ) {
25
25
files += [ path] ;
26
- } else if fs:: file_is_dir ( path)
26
+ } else if fs:: path_is_dir ( path)
27
27
&& !contains ( path, "compile-fail" )
28
28
&& !contains ( path, "build" ) {
29
29
for p in fs:: list_dir ( path) {
Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ import os_fs;
12
12
13
13
#[ abi = "cdecl" ]
14
14
native mod rustrt {
15
- fn rust_file_is_dir ( path : str:: sbuf ) -> int ;
15
+ fn rust_path_is_dir ( path : str:: sbuf ) -> int ;
16
+ fn rust_path_exists ( path : str:: sbuf ) -> int ;
16
17
}
17
18
18
19
/*
@@ -110,12 +111,21 @@ fn connect_many(paths: [path]) : vec::is_not_empty(paths) -> path {
110
111
}
111
112
112
113
/*
113
- Function: file_id_dir
114
+ Function: path_is_dir
114
115
115
116
Indicates whether a path represents a directory.
116
117
*/
117
- fn file_is_dir ( p : path ) -> bool {
118
- ret str:: as_buf ( p, { |buf| rustrt:: rust_file_is_dir ( buf) != 0 } ) ;
118
+ fn path_is_dir ( p : path ) -> bool {
119
+ ret str:: as_buf ( p, { |buf| rustrt:: rust_path_is_dir ( buf) != 0 } ) ;
120
+ }
121
+
122
+ /*
123
+ Function: path_exists
124
+
125
+ Indicates whether a path exists.
126
+ */
127
+ fn path_exists ( p : path ) -> bool {
128
+ ret str:: as_buf ( p, { |buf| rustrt:: rust_path_exists ( buf) != 0 } ) ;
119
129
}
120
130
121
131
/*
Original file line number Diff line number Diff line change @@ -319,14 +319,23 @@ rust_list_files(rust_str *path) {
319
319
}
320
320
321
321
extern " C" CDECL int
322
- rust_file_is_dir (char *path) {
322
+ rust_path_is_dir (char *path) {
323
323
struct stat buf;
324
324
if (stat (path, &buf)) {
325
325
return 0 ;
326
326
}
327
327
return S_ISDIR (buf.st_mode );
328
328
}
329
329
330
+ extern " C" CDECL int
331
+ rust_path_exists (char *path) {
332
+ struct stat buf;
333
+ if (stat (path, &buf)) {
334
+ return 0 ;
335
+ }
336
+ return 1 ;
337
+ }
338
+
330
339
extern " C" CDECL FILE* rust_get_stdin () {return stdin;}
331
340
extern " C" CDECL FILE* rust_get_stdout () {return stdout;}
332
341
extern " C" CDECL FILE* rust_get_stderr () {return stderr;}
Original file line number Diff line number Diff line change @@ -28,7 +28,8 @@ rand_free
28
28
rand_new
29
29
rand_next
30
30
refcount
31
- rust_file_is_dir
31
+ rust_path_is_dir
32
+ rust_path_exists
32
33
rust_getcwd
33
34
rust_get_stdin
34
35
rust_get_stdout
@@ -80,4 +81,4 @@ rust_uv_run
80
81
rust_uv_unref
81
82
rust_uv_idle_init
82
83
rust_uv_idle_start
83
- rust_uv_size_of_idle_t
84
+ rust_uv_size_of_idle_t
Original file line number Diff line number Diff line change @@ -26,9 +26,15 @@ fn list_dir() {
26
26
}
27
27
28
28
#[ test]
29
- fn file_is_dir ( ) {
30
- assert ( fs:: file_is_dir ( "." ) ) ;
31
- assert ( !fs:: file_is_dir ( "test/stdtest/fs.rs" ) ) ;
29
+ fn path_is_dir ( ) {
30
+ assert ( fs:: path_is_dir ( "." ) ) ;
31
+ assert ( !fs:: path_is_dir ( "test/stdtest/fs.rs" ) ) ;
32
+ }
33
+
34
+ #[ test]
35
+ fn path_exists ( ) {
36
+ assert ( fs:: path_exists ( "." ) ) ;
37
+ assert ( !fs:: path_exists ( "test/nonexistent-bogus-path" ) ) ;
32
38
}
33
39
34
40
fn ps ( ) -> str {
@@ -214,4 +220,4 @@ fn splitext_nobasename() {
214
220
let ( base, ext) = fs:: splitext ( "oh.my/" ) ;
215
221
assert base == "oh.my/" ;
216
222
assert ext == "" ;
217
- }
223
+ }
You can’t perform that action at this time.
0 commit comments