Skip to content

Commit 4ef619d

Browse files
committed
---
yaml --- r: 152492 b: refs/heads/try2 c: 03ec8e5 h: refs/heads/master v: v3
1 parent 9124e4c commit 4ef619d

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 298412a6e87be2213bbfc5e6fada9795c405ea13
8+
refs/heads/try2: 03ec8e5cc91b3b6b6ab98ef70aa63a0965c5f6c1
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/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)