Skip to content

Commit cf5e518

Browse files
committed
std: Rebase better errors on master
1 parent 97102d7 commit cf5e518

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/libstd/io/fs.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,15 @@ fs::unlink(&path);
5252
use c_str::ToCStr;
5353
use clone::Clone;
5454
use collections::Collection;
55+
use io::standard_error;
5556
use io::{FilePermission, Write, UnstableFileStat, Open, FileAccess, FileMode};
5657
use io::{IoResult, IoError, FileStat, SeekStyle, Seek, Writer, Reader};
5758
use io::{Read, Truncate, SeekCur, SeekSet, ReadWrite, SeekEnd, Append};
58-
use io;
59+
use io::UpdateIoError;
5960
use io;
6061
use iter::Iterator;
6162
use kinds::Send;
63+
use libc;
6264
use option::{Some, None, Option};
6365
use owned::Box;
6466
use path::{Path, GenericPath};
@@ -67,6 +69,7 @@ use result::{Err, Ok};
6769
use rt::rtio::LocalIo;
6870
use rt::rtio;
6971
use slice::ImmutableVector;
72+
use string::String;
7073
use vec::Vec;
7174

7275
/// Unconstrained file access type that exposes read and write operations
@@ -128,18 +131,18 @@ impl File {
128131
pub fn open_mode(path: &Path,
129132
mode: FileMode,
130133
access: FileAccess) -> IoResult<File> {
131-
let mode = match mode {
134+
let rtio_mode = match mode {
132135
Open => rtio::Open,
133136
Append => rtio::Append,
134137
Truncate => rtio::Truncate,
135138
};
136-
let access = match access {
139+
let rtio_access = match access {
137140
Read => rtio::Read,
138141
Write => rtio::Write,
139142
ReadWrite => rtio::ReadWrite,
140143
};
141144
let err = LocalIo::maybe_raise(|io| {
142-
io.fs_open(&path.to_c_str(), mode, access).map(|fd| {
145+
io.fs_open(&path.to_c_str(), rtio_mode, rtio_access).map(|fd| {
143146
File {
144147
path: path.clone(),
145148
fd: fd,
@@ -775,7 +778,8 @@ impl Reader for File {
775778
e, file.path.display()))
776779
}
777780

778-
let result: IoResult<int> = update_err(self.fd.read(buf), self);
781+
let result = update_err(self.fd.read(buf)
782+
.map_err(IoError::from_rtio_error), self);
779783

780784
match result {
781785
Ok(read) => {
@@ -785,14 +789,14 @@ impl Reader for File {
785789
_ => Ok(read as uint)
786790
}
787791
},
788-
Err(e) => Err(IoError::from_rtio_error(e)),
792+
Err(e) => Err(e)
789793
}
790794
}
791795
}
792796

793797
impl Writer for File {
794798
fn write(&mut self, buf: &[u8]) -> IoResult<()> {
795-
let err = self.fd.write(buf).map_err(IoError::from_rtio_error)
799+
let err = self.fd.write(buf).map_err(IoError::from_rtio_error);
796800
err.update_err("couldn't write to file",
797801
|e| format!("{}; path={}", e, self.path.display()))
798802
}

0 commit comments

Comments
 (0)