Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
8dc5c445
R
Rust
项目概览
int
/
Rust
12 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8dc5c445
编写于
12月 16, 2011
作者:
G
Graydon Hoare
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1318 from elly/cargo
std: file_is_dir -> path_is_dir, add path_exists
上级
b1126878
89e880d6
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
39 addition
and
13 deletion
+39
-13
src/cargo/cargo.rs
src/cargo/cargo.rs
+1
-1
src/fuzzer/fuzzer.rs
src/fuzzer/fuzzer.rs
+1
-1
src/libstd/fs.rs
src/libstd/fs.rs
+14
-4
src/rt/rust_builtin.cpp
src/rt/rust_builtin.cpp
+10
-1
src/rt/rustrt.def.in
src/rt/rustrt.def.in
+3
-2
src/test/stdtest/fs.rs
src/test/stdtest/fs.rs
+10
-4
未找到文件。
src/cargo/cargo.rs
浏览文件 @
8dc5c445
...
...
@@ -112,7 +112,7 @@ fn rest(s: str, start: uint) -> str {
}
fn
need_dir
(
s
:
str
)
{
if
fs
::
file
_is_dir
(
s
)
{
ret
;
}
if
fs
::
path
_is_dir
(
s
)
{
ret
;
}
if
!
fs
::
make_dir
(
s
,
0x1c0i32
)
{
fail
#
fmt
[
"can't make_dir %s"
,
s
];
}
...
...
src/fuzzer/fuzzer.rs
浏览文件 @
8dc5c445
...
...
@@ -23,7 +23,7 @@ fn contains(haystack: str, needle: str) -> bool {
fn
find_rust_files
(
&
files
:
[
str
],
path
:
str
)
{
if
str
::
ends_with
(
path
,
".rs"
)
{
files
+=
[
path
];
}
else
if
fs
::
file
_is_dir
(
path
)
}
else
if
fs
::
path
_is_dir
(
path
)
&&
!
contains
(
path
,
"compile-fail"
)
&&
!
contains
(
path
,
"build"
)
{
for
p
in
fs
::
list_dir
(
path
)
{
...
...
src/libstd/fs.rs
浏览文件 @
8dc5c445
...
...
@@ -12,7 +12,8 @@
#[abi
=
"cdecl"
]
native
mod
rustrt
{
fn
rust_file_is_dir
(
path
:
str
::
sbuf
)
->
int
;
fn
rust_path_is_dir
(
path
:
str
::
sbuf
)
->
int
;
fn
rust_path_exists
(
path
:
str
::
sbuf
)
->
int
;
}
/*
...
...
@@ -110,12 +111,21 @@ fn connect_many(paths: [path]) : vec::is_not_empty(paths) -> path {
}
/*
Function:
file_id
_dir
Function:
path_is
_dir
Indicates whether a path represents a directory.
*/
fn
file_is_dir
(
p
:
path
)
->
bool
{
ret
str
::
as_buf
(
p
,
{|
buf
|
rustrt
::
rust_file_is_dir
(
buf
)
!=
0
});
fn
path_is_dir
(
p
:
path
)
->
bool
{
ret
str
::
as_buf
(
p
,
{|
buf
|
rustrt
::
rust_path_is_dir
(
buf
)
!=
0
});
}
/*
Function: path_exists
Indicates whether a path exists.
*/
fn
path_exists
(
p
:
path
)
->
bool
{
ret
str
::
as_buf
(
p
,
{|
buf
|
rustrt
::
rust_path_exists
(
buf
)
!=
0
});
}
/*
...
...
src/rt/rust_builtin.cpp
浏览文件 @
8dc5c445
...
...
@@ -319,7 +319,7 @@ rust_list_files(rust_str *path) {
}
extern
"C"
CDECL
int
rust_
file
_is_dir
(
char
*
path
)
{
rust_
path
_is_dir
(
char
*
path
)
{
struct
stat
buf
;
if
(
stat
(
path
,
&
buf
))
{
return
0
;
...
...
@@ -327,6 +327,15 @@ rust_file_is_dir(char *path) {
return
S_ISDIR
(
buf
.
st_mode
);
}
extern
"C"
CDECL
int
rust_path_exists
(
char
*
path
)
{
struct
stat
buf
;
if
(
stat
(
path
,
&
buf
))
{
return
0
;
}
return
1
;
}
extern
"C"
CDECL
FILE
*
rust_get_stdin
()
{
return
stdin
;}
extern
"C"
CDECL
FILE
*
rust_get_stdout
()
{
return
stdout
;}
extern
"C"
CDECL
FILE
*
rust_get_stderr
()
{
return
stderr
;}
...
...
src/rt/rustrt.def.in
浏览文件 @
8dc5c445
...
...
@@ -28,7 +28,8 @@ rand_free
rand_new
rand_next
refcount
rust_file_is_dir
rust_path_is_dir
rust_path_exists
rust_getcwd
rust_get_stdin
rust_get_stdout
...
...
@@ -80,4 +81,4 @@ rust_uv_run
rust_uv_unref
rust_uv_idle_init
rust_uv_idle_start
rust_uv_size_of_idle_t
\ No newline at end of file
rust_uv_size_of_idle_t
src/test/stdtest/fs.rs
浏览文件 @
8dc5c445
...
...
@@ -26,9 +26,15 @@ fn list_dir() {
}
#[test]
fn
file_is_dir
()
{
assert
(
fs
::
file_is_dir
(
"."
));
assert
(
!
fs
::
file_is_dir
(
"test/stdtest/fs.rs"
));
fn
path_is_dir
()
{
assert
(
fs
::
path_is_dir
(
"."
));
assert
(
!
fs
::
path_is_dir
(
"test/stdtest/fs.rs"
));
}
#[test]
fn
path_exists
()
{
assert
(
fs
::
path_exists
(
"."
));
assert
(
!
fs
::
path_exists
(
"test/nonexistent-bogus-path"
));
}
fn
ps
()
->
str
{
...
...
@@ -214,4 +220,4 @@ fn splitext_nobasename() {
let
(
base
,
ext
)
=
fs
::
splitext
(
"oh.my/"
);
assert
base
==
"oh.my/"
;
assert
ext
==
""
;
}
\ No newline at end of file
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录