about summary refs log tree commit diff
path: root/src/libcore/io.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcore/io.rs')
-rw-r--r--src/libcore/io.rs48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/libcore/io.rs b/src/libcore/io.rs
index b04bb15f5e3..50e7a42b7b1 100644
--- a/src/libcore/io.rs
+++ b/src/libcore/io.rs
@@ -589,11 +589,11 @@ pub fn file_reader(path: &Path) -> Result<@Reader, ~str> {
 
 // Byte readers
 pub struct BytesReader {
-    bytes: &self/[u8],
+    bytes: &'self [u8],
     mut pos: uint
 }
 
-impl Reader for BytesReader/&self {
+impl Reader for BytesReader<'self> {
     fn read(&self, bytes: &mut [u8], len: uint) -> uint {
         let count = uint::min(len, self.bytes.len() - self.pos);
 
@@ -683,7 +683,7 @@ impl Writer for *libc::FILE {
                                         *self);
                 if nout != len as size_t {
                     error!("error writing buffer");
-                    log(error, os::last_os_error());
+                    error!("%s", os::last_os_error());
                     fail!();
                 }
             }
@@ -733,7 +733,7 @@ impl Writer for fd_t {
                     let nout = libc::write(*self, vb, len as size_t);
                     if nout < 0 as ssize_t {
                         error!("error writing buffer");
-                        log(error, os::last_os_error());
+                        error!("%s", os::last_os_error());
                         fail!();
                     }
                     count += nout as uint;
@@ -785,8 +785,7 @@ pub fn fd_writer(fd: fd_t, cleanup: bool) -> @Writer {
 
 
 pub fn mk_file_writer(path: &Path, flags: &[FileFlag])
-    -> Result<Writer, ~str> {
-
+                   -> Result<@Writer, ~str> {
     #[cfg(windows)]
     fn wb() -> c_int {
       (O_WRONLY | libc::consts::os::extra::O_BINARY) as c_int
@@ -1079,22 +1078,24 @@ impl<T:Writer> WriterUtil for T {
 }
 
 #[allow(non_implicitly_copyable_typarams)]
-pub fn file_writer(path: &Path, flags: &[FileFlag]) -> Result<Writer, ~str> {
+pub fn file_writer(path: &Path, flags: &[FileFlag]) -> Result<@Writer, ~str> {
     mk_file_writer(path, flags).chain(|w| result::Ok(w))
 }
 
 
 // FIXME: fileflags // #2004
-pub fn buffered_file_writer(path: &Path) -> Result<Writer, ~str> {
+pub fn buffered_file_writer(path: &Path) -> Result<@Writer, ~str> {
     unsafe {
         let f = do os::as_c_charp(path.to_str()) |pathbuf| {
             do os::as_c_charp("w") |modebuf| {
                 libc::fopen(pathbuf, modebuf)
             }
         };
-        return if f as uint == 0u { result::Err(~"error opening "
-                                                + path.to_str()) }
-        else { result::Ok(FILE_writer(f, true)) }
+        return if f as uint == 0u {
+            result::Err(~"error opening " + path.to_str())
+        } else {
+            result::Ok(FILE_writer(f, true))
+        }
     }
 }
 
@@ -1115,7 +1116,7 @@ pub struct BytesWriter {
 impl Writer for BytesWriter {
     fn write(&self, v: &[const u8]) {
         let v_len = v.len();
-        let bytes_len = self.bytes.len();
+        let bytes_len = vec::uniq_len(&const self.bytes);
 
         let count = uint::max(bytes_len, self.pos + v_len);
         vec::reserve(&mut self.bytes, count);
@@ -1130,7 +1131,7 @@ impl Writer for BytesWriter {
     }
     fn seek(&self, offset: int, whence: SeekStyle) {
         let pos = self.pos;
-        let len = self.bytes.len();
+        let len = vec::uniq_len(&const self.bytes);
         self.pos = seek_in_buf(offset, pos, len, whence);
     }
     fn tell(&self) -> uint { self.pos }
@@ -1142,14 +1143,14 @@ pub pure fn BytesWriter() -> BytesWriter {
     BytesWriter { bytes: ~[], mut pos: 0u }
 }
 
-pub pure fn with_bytes_writer(f: &fn(Writer)) -> ~[u8] {
+pub pure fn with_bytes_writer(f: &fn(@Writer)) -> ~[u8] {
     let wr = @BytesWriter();
-    f(wr as Writer);
+    f(wr as @Writer);
     let @BytesWriter{bytes, _} = wr;
     return bytes;
 }
 
-pub pure fn with_str_writer(f: &fn(Writer)) -> ~str {
+pub pure fn with_str_writer(f: &fn(@Writer)) -> ~str {
     let mut v = with_bytes_writer(f);
 
     // FIXME (#3758): This should not be needed.
@@ -1277,8 +1278,8 @@ pub mod fsync {
     pub trait FSyncable { fn fsync(&self, l: Level) -> int; }
 
     // Call o.fsync after executing blk
-    pub fn obj_sync(o: FSyncable, opt_level: Option<Level>,
-                    blk: &fn(v: Res<FSyncable>)) {
+    pub fn obj_sync(o: @FSyncable, opt_level: Option<Level>,
+                    blk: &fn(v: Res<@FSyncable>)) {
         blk(Res(Arg {
             val: o, opt_level: opt_level,
             fsync_fn: |o, l| o.fsync(l)
@@ -1288,7 +1289,6 @@ pub mod fsync {
 
 #[cfg(test)]
 mod tests {
-    use debug;
     use i32;
     use io::{BytesWriter, SeekCur, SeekEnd, SeekSet};
     use io;
@@ -1301,19 +1301,19 @@ mod tests {
     #[test]
     fn test_simple() {
         let tmpfile = &Path("tmp/lib-io-test-simple.tmp");
-        log(debug, tmpfile);
+        debug!(tmpfile);
         let frood: ~str =
             ~"A hoopy frood who really knows where his towel is.";
-        log(debug, copy frood);
+        debug!(copy frood);
         {
-            let out: io::Writer =
+            let out: @io::Writer =
                 result::get(
                     &io::file_writer(tmpfile, ~[io::Create, io::Truncate]));
             out.write_str(frood);
         }
-        let inp: io::Reader = result::get(&io::file_reader(tmpfile));
+        let inp: @io::Reader = result::get(&io::file_reader(tmpfile));
         let frood2: ~str = inp.read_c_str();
-        log(debug, copy frood2);
+        debug!(copy frood2);
         fail_unless!(frood == frood2);
     }