Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
vnotepad
Exa
提交
4295b243
E
Exa
项目概览
vnotepad
/
Exa
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
Exa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
4295b243
编写于
6月 27, 2017
作者:
B
Benjamin Sago
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make Dir construction a bit cleaner
上级
20793ce7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
10 addition
and
13 deletion
+10
-13
src/fs/dir.rs
src/fs/dir.rs
+9
-12
src/fs/file.rs
src/fs/file.rs
+1
-1
未找到文件。
src/fs/dir.rs
浏览文件 @
4295b243
...
...
@@ -36,24 +36,21 @@ impl Dir {
/// The `read_dir` iterator doesn’t actually yield the `.` and `..`
/// entries, so if the user wants to see them, we’ll have to add them
/// ourselves after the files have been read.
pub
fn
read_dir
(
path
:
&
Path
,
dots
:
DotFilter
,
git
:
bool
)
->
IOResult
<
Dir
>
{
let
mut
paths
:
Vec
<
PathBuf
>
=
try!
(
fs
::
read_dir
(
path
)
?
.map
(|
result
|
result
.map
(|
entry
|
entry
.path
()))
.collect
());
pub
fn
read_dir
(
path
:
PathBuf
,
dots
:
DotFilter
,
git
:
bool
)
->
IOResult
<
Dir
>
{
let
mut
contents
:
Vec
<
PathBuf
>
=
try!
(
fs
::
read_dir
(
&
path
)
?
.map
(|
result
|
result
.map
(|
entry
|
entry
.path
()))
.collect
());
match
dots
{
DotFilter
::
JustFiles
=>
path
s
.retain
(|
p
|
p
.file_name
()
.and_then
(|
name
|
name
.to_str
())
.map
(|
s
|
!
s
.starts_with
(
'.'
))
.unwrap_or
(
true
)),
DotFilter
::
JustFiles
=>
content
s
.retain
(|
p
|
p
.file_name
()
.and_then
(|
name
|
name
.to_str
())
.map
(|
s
|
!
s
.starts_with
(
'.'
))
.unwrap_or
(
true
)),
DotFilter
::
Dotfiles
=>
{
/* Don’t add or remove anything */
},
DotFilter
::
DotfilesAndDots
=>
{
path
s
.insert
(
0
,
path
.join
(
".."
));
path
s
.insert
(
0
,
path
.join
(
"."
));
content
s
.insert
(
0
,
path
.join
(
".."
));
content
s
.insert
(
0
,
path
.join
(
"."
));
}
}
Ok
(
Dir
{
contents
:
paths
,
path
:
path
.to_path_buf
(),
git
:
if
git
{
Git
::
scan
(
path
)
.ok
()
}
else
{
None
},
})
let
git
=
if
git
{
Git
::
scan
(
&
path
)
.ok
()
}
else
{
None
};
Ok
(
Dir
{
contents
,
path
,
git
})
}
/// Produce an iterator of IO results of trying to read all the files in
...
...
src/fs/file.rs
浏览文件 @
4295b243
...
...
@@ -95,7 +95,7 @@ impl<'dir> File<'dir> {
/// Returns an IO error upon failure, but this shouldn't be used to check
/// if a `File` is a directory or not! For that, just use `is_directory()`.
pub
fn
to_dir
(
&
self
,
dots
:
DotFilter
,
scan_for_git
:
bool
)
->
IOResult
<
Dir
>
{
Dir
::
read_dir
(
&*
self
.path
,
dots
,
scan_for_git
)
Dir
::
read_dir
(
self
.path
.clone
()
,
dots
,
scan_for_git
)
}
/// Whether this file is a regular file on the filesystem - that is, not a
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录