1
- // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1
+ // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
2
2
// file at the top-level directory of this distribution and at
3
3
// http://rust-lang.org/COPYRIGHT.
4
4
//
@@ -27,8 +27,8 @@ use io::{IoResult, retry};
27
27
#[ cfg( windows) ] use std:: str;
28
28
29
29
pub fn keep_going ( data : & [ u8 ] , f : |* u8 , uint| -> i64) -> i64 {
30
- #[ cfg( windows) ] static eintr : int = 0 ; // doesn't matter
31
- #[ cfg( not( windows) ) ] static eintr : int = libc:: EINTR as int ;
30
+ #[ cfg( windows) ] static EINTR : int = 0 ; // doesn't matter
31
+ #[ cfg( not( windows) ) ] static EINTR : int = libc:: EINTR as int ;
32
32
33
33
let origamt = data. len ( ) ;
34
34
let mut data = data. as_ptr ( ) ;
@@ -37,9 +37,9 @@ pub fn keep_going(data: &[u8], f: |*u8, uint| -> i64) -> i64 {
37
37
let mut ret;
38
38
loop {
39
39
ret = f ( data, amt) ;
40
- if cfg ! ( windows) { break } // windows has no eintr
41
- // if we get an eintr , then try again
42
- if ret != -1 || os:: errno ( ) as int != eintr { break }
40
+ if cfg ! ( windows) { break } // windows has no EINTR
41
+ // if we get an EINTR , then try again
42
+ if ret != -1 || os:: errno ( ) as int != EINTR { break }
43
43
}
44
44
if ret == 0 {
45
45
break
@@ -53,6 +53,7 @@ pub fn keep_going(data: &[u8], f: |*u8, uint| -> i64) -> i64 {
53
53
return ( origamt - amt) as i64 ;
54
54
}
55
55
56
+ #[ allow( non_camel_case_types) ]
56
57
pub type fd_t = libc:: c_int ;
57
58
58
59
pub struct FileDesc {
@@ -77,12 +78,12 @@ impl FileDesc {
77
78
// native::io wanting to use them is forced to have all the
78
79
// rtio traits in scope
79
80
pub fn inner_read ( & mut self , buf : & mut [ u8 ] ) -> Result < uint , IoError > {
80
- #[ cfg( windows) ] type rlen = libc:: c_uint ;
81
- #[ cfg( not( windows) ) ] type rlen = libc:: size_t ;
81
+ #[ cfg( windows) ] type RLen = libc:: c_uint ;
82
+ #[ cfg( not( windows) ) ] type RLen = libc:: size_t ;
82
83
let ret = retry ( || unsafe {
83
84
libc:: read ( self . fd ,
84
85
buf. as_ptr ( ) as * mut libc:: c_void ,
85
- buf. len ( ) as rlen ) as libc:: c_int
86
+ buf. len ( ) as RLen ) as libc:: c_int
86
87
} ) ;
87
88
if ret == 0 {
88
89
Err ( io:: standard_error ( io:: EndOfFile ) )
@@ -93,11 +94,11 @@ impl FileDesc {
93
94
}
94
95
}
95
96
pub fn inner_write ( & mut self , buf : & [ u8 ] ) -> Result < ( ) , IoError > {
96
- #[ cfg( windows) ] type wlen = libc:: c_uint ;
97
- #[ cfg( not( windows) ) ] type wlen = libc:: size_t ;
97
+ #[ cfg( windows) ] type WLen = libc:: c_uint ;
98
+ #[ cfg( not( windows) ) ] type WLen = libc:: size_t ;
98
99
let ret = keep_going ( buf, |buf, len| {
99
100
unsafe {
100
- libc:: write ( self . fd , buf as * libc:: c_void , len as wlen ) as i64
101
+ libc:: write ( self . fd , buf as * libc:: c_void , len as WLen ) as i64
101
102
}
102
103
} ) ;
103
104
if ret < 0 {
@@ -782,7 +783,7 @@ fn mkstat(stat: &libc::stat, path: &CString) -> io::FileStat {
782
783
path : Path :: new ( path) ,
783
784
size : stat. st_size as u64 ,
784
785
kind : kind,
785
- perm : ( stat. st_mode ) as io:: FilePermission & io:: AllPermissions ,
786
+ perm : ( stat. st_mode ) as io:: FilePermission & io:: ALL_PERMISSIONS ,
786
787
created : stat. st_ctime as u64 ,
787
788
modified : stat. st_mtime as u64 ,
788
789
accessed : stat. st_atime as u64 ,
@@ -831,7 +832,7 @@ fn mkstat(stat: &libc::stat, path: &CString) -> io::FileStat {
831
832
path : Path :: new ( path) ,
832
833
size : stat. st_size as u64 ,
833
834
kind : kind,
834
- perm : ( stat. st_mode ) as io:: FilePermission & io:: AllPermissions ,
835
+ perm : ( stat. st_mode ) as io:: FilePermission & io:: ALL_PERMISSIONS ,
835
836
created : mktime ( stat. st_ctime as u64 , stat. st_ctime_nsec as u64 ) ,
836
837
modified : mktime ( stat. st_mtime as u64 , stat. st_mtime_nsec as u64 ) ,
837
838
accessed : mktime ( stat. st_atime as u64 , stat. st_atime_nsec as u64 ) ,
0 commit comments