Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
6311856b
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
6311856b
编写于
8月 22, 2013
作者:
J
Jeff Olson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
std: slight refactor on UvFilestream seek behavior, pre-seek-refactor
上级
94b84a85
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
34 addition
and
38 deletion
+34
-38
src/libstd/rt/io/file.rs
src/libstd/rt/io/file.rs
+2
-8
src/libstd/rt/rtio.rs
src/libstd/rt/rtio.rs
+2
-1
src/libstd/rt/uv/uvio.rs
src/libstd/rt/uv/uvio.rs
+30
-29
未找到文件。
src/libstd/rt/io/file.rs
浏览文件 @
6311856b
...
...
@@ -170,15 +170,9 @@ fn tell(&self) -> u64 {
}
fn
seek
(
&
mut
self
,
pos
:
i64
,
style
:
SeekStyle
)
{
use
libc
::{
SEEK_SET
,
SEEK_CUR
,
SEEK_END
};
let
whence
=
match
style
{
SeekSet
=>
SEEK_SET
,
SeekCur
=>
SEEK_CUR
,
SeekEnd
=>
SEEK_END
}
as
i64
;
match
self
.fd
.seek
(
pos
,
whence
)
{
match
self
.fd
.seek
(
pos
,
style
)
{
Ok
(
_
)
=>
{
// successful seek resets EOF ind
o
cator
// successful seek resets EOF ind
i
cator
self
.last_nread
=
-
1
;
()
},
...
...
src/libstd/rt/rtio.rs
浏览文件 @
6311856b
...
...
@@ -17,6 +17,7 @@
use
rt
::
uv
::
uvio
;
use
path
::
Path
;
use
super
::
io
::
support
::
PathLike
;
use
super
::
io
::{
SeekStyle
};
// XXX: ~object doesn't work currently so these are some placeholder
// types to use instead
...
...
@@ -118,7 +119,7 @@ pub trait RtioFileStream {
fn
write
(
&
mut
self
,
buf
:
&
[
u8
])
->
Result
<
(),
IoError
>
;
fn
pread
(
&
mut
self
,
buf
:
&
mut
[
u8
],
offset
:
u64
)
->
Result
<
int
,
IoError
>
;
fn
pwrite
(
&
mut
self
,
buf
:
&
[
u8
],
offset
:
u64
)
->
Result
<
(),
IoError
>
;
fn
seek
(
&
mut
self
,
pos
:
i64
,
whence
:
i64
)
->
Result
<
()
,
IoError
>
;
fn
seek
(
&
mut
self
,
pos
:
i64
,
whence
:
SeekStyle
)
->
Result
<
u64
,
IoError
>
;
fn
tell
(
&
self
)
->
Result
<
u64
,
IoError
>
;
fn
flush
(
&
mut
self
)
->
Result
<
(),
IoError
>
;
}
src/libstd/rt/uv/uvio.rs
浏览文件 @
6311856b
...
...
@@ -21,7 +21,7 @@
use
result
::
*
;
use
rt
::
io
::
IoError
;
use
rt
::
io
::
net
::
ip
::{
SocketAddr
,
IpAddr
};
use
rt
::
io
::{
standard_error
,
OtherIoError
};
use
rt
::
io
::{
standard_error
,
OtherIoError
,
SeekStyle
,
SeekSet
,
SeekCur
,
SeekEnd
};
use
rt
::
local
::
Local
;
use
rt
::
rtio
::
*
;
use
rt
::
sched
::{
Scheduler
,
SchedHandle
};
...
...
@@ -31,7 +31,7 @@
use
rt
::
uv
::
net
::{
UvIpv4SocketAddr
,
UvIpv6SocketAddr
};
use
unstable
::
sync
::
Exclusive
;
use
super
::
super
::
io
::
support
::
PathLike
;
use
libc
::{
lseek
,
c_long
,
SEEK_CUR
};
use
libc
::{
lseek
,
c_long
};
#[cfg(test)]
use
container
::
Container
;
#[cfg(test)]
use
unstable
::
run_in_bare_thread
;
...
...
@@ -1122,6 +1122,22 @@ fn base_write(&mut self, buf: &[u8], offset: i64) -> Result<(), IoError> {
};
result_cell
.take
()
}
fn
seek_common
(
&
mut
self
,
pos
:
i64
,
whence
:
c_int
)
->
Result
<
u64
,
IoError
>
{
#[fixed_stack_segment]
;
#[inline(never)]
;
unsafe
{
match
lseek
((
*
self
.fd
),
pos
as
c_long
,
whence
)
{
-
1
=>
{
Err
(
IoError
{
kind
:
OtherIoError
,
desc
:
"Failed to lseek."
,
detail
:
None
})
},
n
=>
Ok
(
n
as
u64
)
}
}
}
}
impl
Drop
for
UvFileStream
{
...
...
@@ -1155,35 +1171,20 @@ fn pread(&mut self, buf: &mut [u8], offset: u64) -> Result<int, IoError> {
fn
pwrite
(
&
mut
self
,
buf
:
&
[
u8
],
offset
:
u64
)
->
Result
<
(),
IoError
>
{
self
.base_write
(
buf
,
offset
as
i64
)
}
fn
seek
(
&
mut
self
,
pos
:
i64
,
whence
:
i64
)
->
Result
<
(),
IoError
>
{
#[fixed_stack_segment]
;
#[inline(never)]
;
unsafe
{
match
lseek
((
*
self
.fd
),
pos
as
c_long
,
whence
as
c_int
)
{
-
1
=>
{
Err
(
IoError
{
kind
:
OtherIoError
,
desc
:
"Failed to lseek."
,
detail
:
None
})
},
_
=>
Ok
(())
}
}
fn
seek
(
&
mut
self
,
pos
:
i64
,
whence
:
SeekStyle
)
->
Result
<
u64
,
IoError
>
{
use
libc
::{
SEEK_SET
,
SEEK_CUR
,
SEEK_END
};
let
whence
=
match
whence
{
SeekSet
=>
SEEK_SET
,
SeekCur
=>
SEEK_CUR
,
SeekEnd
=>
SEEK_END
};
self
.seek_common
(
pos
,
whence
)
}
fn
tell
(
&
self
)
->
Result
<
u64
,
IoError
>
{
#[fixed_stack_segment]
;
#[inline(never)]
;
unsafe
{
match
lseek
((
*
self
.fd
),
0
,
SEEK_CUR
)
{
-
1
=>
{
Err
(
IoError
{
kind
:
OtherIoError
,
desc
:
"Failed to lseek, needed to tell()."
,
detail
:
None
})
},
n
=>
Ok
(
n
as
u64
)
}
}
use
libc
::
SEEK_CUR
;
// this is temporary
let
self_
=
unsafe
{
cast
::
transmute
::
<&
UvFileStream
,
&
mut
UvFileStream
>
(
self
)
};
self_
.seek_common
(
0
,
SEEK_CUR
)
}
fn
flush
(
&
mut
self
)
->
Result
<
(),
IoError
>
{
Ok
(())
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录