Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
vnotepad
Exa
提交
6ade060e
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,发现更多精彩内容 >>
提交
6ade060e
编写于
11月 25, 2014
作者:
B
Ben S
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use curlies consistently
上级
e1d3512a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
29 addition
and
29 deletion
+29
-29
src/file.rs
src/file.rs
+15
-11
src/options.rs
src/options.rs
+5
-6
src/sort.rs
src/sort.rs
+2
-1
src/unix.rs
src/unix.rs
+7
-11
未找到文件。
src/file.rs
浏览文件 @
6ade060e
...
...
@@ -37,7 +37,7 @@ impl<'a> File<'a> {
// encounters a link that's target is non-existent.
fs
::
lstat
(
&
path
)
.map
(|
stat
|
File
::
with_stat
(
stat
,
path
.clone
(),
parent
))
}
pub
fn
with_stat
(
stat
:
io
::
FileStat
,
path
:
Path
,
parent
:
Option
<&
'a
Dir
<
'a
>>
)
->
File
<
'a
>
{
let
v
=
path
.filename
()
.unwrap
();
// fails if / or . or ..
let
filename
=
String
::
from_utf8
(
v
.to_vec
())
.unwrap_or_else
(|
_
|
panic!
(
"Name was not valid UTF-8"
));
...
...
@@ -79,7 +79,7 @@ impl<'a> File<'a> {
if
self
.ext
.is_none
()
{
return
vec!
[];
}
let
ext
=
self
.ext
.clone
()
.unwrap
();
match
ext
.as_slice
()
{
"class"
=>
vec!
[
self
.path
.with_extension
(
"java"
)],
// Java
...
...
@@ -107,11 +107,11 @@ impl<'a> File<'a> {
Permissions
=>
{
self
.permissions_string
()
},
FileName
=>
{
self
.file_name
()
},
FileSize
(
use_iec
)
=>
{
self
.file_size
(
use_iec
)
},
...
...
@@ -127,7 +127,7 @@ impl<'a> File<'a> {
Inode
=>
{
Purple
.paint
(
self
.stat.unstable.inode
.to_string
()
.as_slice
())
},
Blocks
=>
{
if
self
.stat.kind
==
io
::
TypeFile
||
self
.stat.kind
==
io
::
TypeSymlink
{
Cyan
.paint
(
self
.stat.unstable.blocks
.to_string
()
.as_slice
())
...
...
@@ -146,7 +146,7 @@ impl<'a> File<'a> {
let
style
=
if
unix
.uid
==
uid
{
Yellow
.bold
()
}
else
{
Plain
};
style
.paint
(
user_name
.as_slice
())
},
Group
=>
{
let
gid
=
self
.stat.unstable.gid
as
u32
;
unix
.load_group
(
gid
);
...
...
@@ -184,7 +184,8 @@ impl<'a> File<'a> {
fn
target_file_name_and_arrow
(
&
self
,
target_path
:
Path
)
->
String
{
let
v
=
target_path
.filename
()
.unwrap
();
let
filename
=
String
::
from_utf8_lossy
(
v
)
.to_string
();
// Use stat instead of lstat - we *want* to follow links.
let
link_target
=
fs
::
stat
(
&
target_path
)
.map
(|
stat
|
File
{
path
:
target_path
.clone
(),
dir
:
self
.dir
,
...
...
@@ -212,10 +213,12 @@ impl<'a> File<'a> {
// at one of those numbers and gained any information from it.
if
self
.stat.kind
==
io
::
TypeDirectory
{
GREY
.paint
(
"-"
)
}
else
{
}
else
{
let
(
size
,
suffix
)
=
if
use_iec_prefixes
{
format_IEC_bytes
(
self
.stat.size
)
}
else
{
}
else
{
format_metric_bytes
(
self
.stat.size
)
};
...
...
@@ -237,7 +240,7 @@ impl<'a> File<'a> {
pub
fn
file_colour
(
&
self
)
->
Style
{
self
.get_type
()
.style
()
}
fn
has_multiple_links
(
&
self
)
->
bool
{
self
.stat.kind
==
io
::
TypeFile
&&
self
.stat.unstable.nlink
>
1
}
...
...
@@ -264,7 +267,8 @@ impl<'a> File<'a> {
fn
permission_bit
(
bits
:
io
::
FilePermission
,
bit
:
io
::
FilePermission
,
character
:
&
'static
str
,
style
:
Style
)
->
String
{
if
bits
.contains
(
bit
)
{
style
.paint
(
character
.as_slice
())
}
else
{
}
else
{
GREY
.paint
(
"-"
.as_slice
())
}
}
...
...
src/options.rs
浏览文件 @
6ade060e
...
...
@@ -40,7 +40,6 @@ pub struct Options {
pub
view
:
View
,
}
impl
Options
{
pub
fn
getopts
(
args
:
Vec
<
String
>
)
->
Result
<
Options
,
int
>
{
let
opts
=
[
...
...
@@ -59,7 +58,7 @@ impl Options {
getopts
::
optflag
(
"x"
,
"across"
,
"sort multi-column view entries across"
),
getopts
::
optflag
(
"?"
,
"help"
,
"show list of command-line options"
),
];
let
matches
=
match
getopts
::
getopts
(
args
.tail
(),
&
opts
)
{
Ok
(
m
)
=>
m
,
Err
(
e
)
=>
{
...
...
@@ -67,7 +66,7 @@ impl Options {
return
Err
(
1
);
}
};
if
matches
.opt_present
(
"help"
)
{
println!
(
"exa - ls with more features
\n\n
{}"
,
getopts
::
usage
(
"Usage:
\n
exa [options] [files...]"
,
&
opts
))
return
Err
(
2
);
...
...
@@ -83,7 +82,7 @@ impl Options {
view
:
Options
::
view
(
&
matches
),
})
}
fn
view
(
matches
:
&
getopts
::
Matches
)
->
View
{
if
matches
.opt_present
(
"long"
)
{
View
::
Details
(
Options
::
columns
(
matches
))
...
...
@@ -98,7 +97,7 @@ impl Options {
}
}
}
fn
columns
(
matches
:
&
getopts
::
Matches
)
->
Vec
<
Column
>
{
let
mut
columns
=
vec!
[];
...
...
@@ -111,7 +110,7 @@ impl Options {
if
matches
.opt_present
(
"links"
)
{
columns
.push
(
HardLinks
);
}
columns
.push
(
FileSize
(
matches
.opt_present
(
"binary"
)));
if
matches
.opt_present
(
"blocks"
)
{
...
...
src/sort.rs
浏览文件 @
6ade060e
...
...
@@ -24,7 +24,8 @@ impl SortPart {
Some
(
num
)
=>
Numeric
(
num
),
None
=>
Stringular
(
slice
.to_string
()),
}
}
else
{
}
else
{
SortPart
::
Stringular
(
slice
.to_ascii_lower
())
}
}
...
...
src/unix.rs
浏览文件 @
6ade060e
...
...
@@ -104,25 +104,21 @@ impl Unix {
let
mut
i
=
0
;
// The list of members is a pointer to a pointer of
// characters, terminated by a null pointer. So the first call
// to `as_ref` will always succeed, as that memory is
// guaranteed to be there (unless we go past the end of RAM).
// The second call will return None if it's a null pointer.
// characters, terminated by a null pointer.
loop
{
match
unsafe
{
group
.offset
(
i
)
.as_ref
()
}
{
Some
(
&
username
)
=>
{
if
username
==
ptr
::
null
()
{
return
false
;
return
false
;
// username was null, weird
}
else
if
unsafe
{
String
::
from_raw_buf
(
username
as
*
const
u8
)
}
==
*
uname
{
return
true
;
return
true
;
// group found!
}
else
{
i
+=
1
;
i
+=
1
;
// try again with the next group
}
},
None
=>
return
false
,
None
=>
return
false
,
// no more groups to check, and none found
}
}
}
...
...
@@ -137,9 +133,9 @@ impl Unix {
let
group_name
=
unsafe
{
Some
(
String
::
from_raw_buf
(
r
.gr_name
as
*
const
u8
))
};
if
!
self
.groups
.contains_key
(
&
gid
)
{
self
.groups
.insert
(
gid
,
Unix
::
group_membership
(
r
.gr_mem
,
&
self
.username
));
}
}
self
.group_names
.insert
(
gid
,
group_name
);
}
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录