@@ -86,73 +86,10 @@ fn unimpl() -> IoError {
8686 }
8787}
8888
89- fn translate_error ( errno : i32 , detail : bool ) -> IoError {
90- #[ cfg( windows) ]
91- fn get_err ( errno : i32 ) -> ( io:: IoErrorKind , & ' static str ) {
92- match errno {
93- libc:: EOF => ( io:: EndOfFile , "end of file" ) ,
94- libc:: ERROR_NO_DATA => ( io:: BrokenPipe , "the pipe is being closed" ) ,
95- libc:: ERROR_FILE_NOT_FOUND => ( io:: FileNotFound , "file not found" ) ,
96- libc:: ERROR_INVALID_NAME => ( io:: InvalidInput , "invalid file name" ) ,
97- libc:: WSAECONNREFUSED => ( io:: ConnectionRefused , "connection refused" ) ,
98- libc:: WSAECONNRESET => ( io:: ConnectionReset , "connection reset" ) ,
99- libc:: WSAEACCES => ( io:: PermissionDenied , "permission denied" ) ,
100- libc:: WSAEWOULDBLOCK => {
101- ( io:: ResourceUnavailable , "resource temporarily unavailable" )
102- }
103- libc:: WSAENOTCONN => ( io:: NotConnected , "not connected" ) ,
104- libc:: WSAECONNABORTED => ( io:: ConnectionAborted , "connection aborted" ) ,
105- libc:: WSAEADDRNOTAVAIL => ( io:: ConnectionRefused , "address not available" ) ,
106- libc:: WSAEADDRINUSE => ( io:: ConnectionRefused , "address in use" ) ,
107- libc:: ERROR_BROKEN_PIPE => ( io:: EndOfFile , "the pipe has ended" ) ,
108-
109- // libuv maps this error code to EISDIR. we do too. if it is found
110- // to be incorrect, we can add in some more machinery to only
111- // return this message when ERROR_INVALID_FUNCTION after certain
112- // win32 calls.
113- libc:: ERROR_INVALID_FUNCTION => ( io:: InvalidInput ,
114- "illegal operation on a directory" ) ,
115-
116- _ => ( io:: OtherIoError , "unknown error" )
117- }
118- }
119-
120- #[ cfg( not( windows) ) ]
121- fn get_err ( errno : i32 ) -> ( io:: IoErrorKind , & ' static str ) {
122- // FIXME: this should probably be a bit more descriptive...
123- match errno {
124- libc:: EOF => ( io:: EndOfFile , "end of file" ) ,
125- libc:: ECONNREFUSED => ( io:: ConnectionRefused , "connection refused" ) ,
126- libc:: ECONNRESET => ( io:: ConnectionReset , "connection reset" ) ,
127- libc:: EPERM | libc:: EACCES =>
128- ( io:: PermissionDenied , "permission denied" ) ,
129- libc:: EPIPE => ( io:: BrokenPipe , "broken pipe" ) ,
130- libc:: ENOTCONN => ( io:: NotConnected , "not connected" ) ,
131- libc:: ECONNABORTED => ( io:: ConnectionAborted , "connection aborted" ) ,
132- libc:: EADDRNOTAVAIL => ( io:: ConnectionRefused , "address not available" ) ,
133- libc:: EADDRINUSE => ( io:: ConnectionRefused , "address in use" ) ,
134- libc:: ENOENT => ( io:: FileNotFound , "no such file or directory" ) ,
135- libc:: EISDIR => ( io:: InvalidInput , "illegal operation on a directory" ) ,
136-
137- // These two constants can have the same value on some systems, but
138- // different values on others, so we can't use a match clause
139- x if x == libc:: EAGAIN || x == libc:: EWOULDBLOCK =>
140- ( io:: ResourceUnavailable , "resource temporarily unavailable" ) ,
141-
142- _ => ( io:: OtherIoError , "unknown error" )
143- }
144- }
145-
146- let ( kind, desc) = get_err ( errno) ;
147- IoError {
148- kind : kind,
149- desc : desc,
150- detail : if detail { Some ( os:: last_os_error ( ) ) } else { None } ,
151- }
89+ fn last_error ( ) -> IoError {
90+ IoError :: last_error ( )
15291}
15392
154- fn last_error ( ) -> IoError { translate_error ( os:: errno ( ) as i32 , true ) }
155-
15693// unix has nonzero values as errors
15794fn mkerr_libc ( ret : libc:: c_int ) -> IoResult < ( ) > {
15895 if ret != 0 {
0 commit comments