From 4e489246673af1efff371e3a8667ffd7e6733768 Mon Sep 17 00:00:00 2001 From: Tobias Bucher Date: Tue, 23 Aug 2016 10:32:42 +0200 Subject: [PATCH] Rename `{read,write}_offset` to `{read,write}_at`, add a tracking issue --- src/libstd/fs.rs | 30 +++++++++++++++--------------- src/libstd/sys/unix/fd.rs | 4 ++-- src/libstd/sys/unix/fs.rs | 8 ++++---- src/libstd/sys/windows/fs.rs | 8 ++++---- src/libstd/sys/windows/handle.rs | 4 ++-- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 67b234de83d79..654e93144808f 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -356,9 +356,9 @@ impl File { /// /// Note that similar to `File::read`, it is not an error to return a short /// read. - #[unstable(feature = "file_offset", issue = "0")] - pub fn read_offset(&self, buf: &mut [u8], offset: u64) -> io::Result { - self.inner.read_offset(buf, offset) + #[unstable(feature = "file_offset", issue = "35918")] + pub fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result { + self.inner.read_at(buf, offset) } /// Writes a number of bytes starting from a given offset. @@ -368,9 +368,9 @@ impl File { /// /// Note that similar to `File::write`, it is not an error to return a /// short write. - #[unstable(feature = "file_offset", issue = "0")] - pub fn write_offset(&self, buf: &[u8], offset: u64) -> io::Result { - self.inner.write_offset(buf, offset) + #[unstable(feature = "file_offset", issue = "35918")] + pub fn write_at(&self, buf: &[u8], offset: u64) -> io::Result { + self.inner.write_at(buf, offset) } } @@ -1918,9 +1918,9 @@ mod tests { } #[test] - fn file_test_io_read_write_offset() { + fn file_test_io_read_write_at() { let tmpdir = tmpdir(); - let filename = tmpdir.join("file_rt_io_file_test_read_write_offset.txt"); + let filename = tmpdir.join("file_rt_io_file_test_read_write_at.txt"); let mut buf = [0; 256]; let write1 = "asdf"; let write2 = "qwer-"; @@ -1929,9 +1929,9 @@ mod tests { { let oo = OpenOptions::new().create_new(true).write(true).read(true).clone(); let mut rw = check!(oo.open(&filename)); - assert_eq!(check!(rw.write_offset(write1.as_bytes(), 5)), write1.len()); + assert_eq!(check!(rw.write_at(write1.as_bytes(), 5)), write1.len()); assert_eq!(check!(rw.seek(SeekFrom::Current(0))), 0); - assert_eq!(check!(rw.read_offset(&mut buf, 5)), write1.len()); + assert_eq!(check!(rw.read_at(&mut buf, 5)), write1.len()); assert_eq!(str::from_utf8(&buf[..write1.len()]), Ok(write1)); assert_eq!(check!(rw.seek(SeekFrom::Current(0))), 0); assert_eq!(check!(rw.write(write2.as_bytes())), write2.len()); @@ -1939,25 +1939,25 @@ mod tests { assert_eq!(check!(rw.read(&mut buf)), write1.len()); assert_eq!(str::from_utf8(&buf[..write1.len()]), Ok(write1)); assert_eq!(check!(rw.seek(SeekFrom::Current(0))), 9); - assert_eq!(check!(rw.read_offset(&mut buf[..write2.len()], 0)), write2.len()); + assert_eq!(check!(rw.read_at(&mut buf[..write2.len()], 0)), write2.len()); assert_eq!(str::from_utf8(&buf[..write2.len()]), Ok(write2)); assert_eq!(check!(rw.seek(SeekFrom::Current(0))), 9); - assert_eq!(check!(rw.write_offset(write3.as_bytes(), 9)), write3.len()); + assert_eq!(check!(rw.write_at(write3.as_bytes(), 9)), write3.len()); assert_eq!(check!(rw.seek(SeekFrom::Current(0))), 9); } { let mut read = check!(File::open(&filename)); - assert_eq!(check!(read.read_offset(&mut buf, 0)), content.len()); + assert_eq!(check!(read.read_at(&mut buf, 0)), content.len()); assert_eq!(str::from_utf8(&buf[..content.len()]), Ok(content)); assert_eq!(check!(read.seek(SeekFrom::Current(0))), 0); assert_eq!(check!(read.seek(SeekFrom::End(-5))), 9); - assert_eq!(check!(read.read_offset(&mut buf, 0)), content.len()); + assert_eq!(check!(read.read_at(&mut buf, 0)), content.len()); assert_eq!(str::from_utf8(&buf[..content.len()]), Ok(content)); assert_eq!(check!(read.seek(SeekFrom::Current(0))), 9); assert_eq!(check!(read.read(&mut buf)), write3.len()); assert_eq!(str::from_utf8(&buf[..write3.len()]), Ok(write3)); assert_eq!(check!(read.seek(SeekFrom::Current(0))), 14); - assert_eq!(check!(read.read_offset(&mut buf, 0)), content.len()); + assert_eq!(check!(read.read_at(&mut buf, 0)), content.len()); assert_eq!(str::from_utf8(&buf[..content.len()]), Ok(content)); assert_eq!(check!(read.seek(SeekFrom::Current(0))), 14); } diff --git a/src/libstd/sys/unix/fd.rs b/src/libstd/sys/unix/fd.rs index 12c57f0ea5906..1661aad68caab 100644 --- a/src/libstd/sys/unix/fd.rs +++ b/src/libstd/sys/unix/fd.rs @@ -52,7 +52,7 @@ impl FileDesc { (&mut me).read_to_end(buf) } - pub fn read_offset(&self, buf: &mut [u8], offset: u64) -> io::Result { + pub fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result { let ret = cvt(unsafe { libc::pread(self.fd, buf.as_mut_ptr() as *mut c_void, @@ -71,7 +71,7 @@ impl FileDesc { Ok(ret as usize) } - pub fn write_offset(&self, buf: &[u8], offset: u64) -> io::Result { + pub fn write_at(&self, buf: &[u8], offset: u64) -> io::Result { let ret = cvt(unsafe { libc::pwrite(self.fd, buf.as_ptr() as *const c_void, diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index f8ea67a3a44f7..a97b2439ddb56 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -477,16 +477,16 @@ impl File { self.0.read_to_end(buf) } - pub fn read_offset(&self, buf: &mut [u8], offset: u64) -> io::Result { - self.0.read_offset(buf, offset) + pub fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result { + self.0.read_at(buf, offset) } pub fn write(&self, buf: &[u8]) -> io::Result { self.0.write(buf) } - pub fn write_offset(&self, buf: &[u8], offset: u64) -> io::Result { - self.0.write_offset(buf, offset) + pub fn write_at(&self, buf: &[u8], offset: u64) -> io::Result { + self.0.write_at(buf, offset) } pub fn flush(&self) -> io::Result<()> { Ok(()) } diff --git a/src/libstd/sys/windows/fs.rs b/src/libstd/sys/windows/fs.rs index 1fd01800a3d24..393500c84fb62 100644 --- a/src/libstd/sys/windows/fs.rs +++ b/src/libstd/sys/windows/fs.rs @@ -312,8 +312,8 @@ impl File { self.handle.read(buf) } - pub fn read_offset(&self, buf: &mut [u8], offset: u64) -> io::Result { - self.handle.read_offset(buf, offset) + pub fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result { + self.handle.read_at(buf, offset) } pub fn read_to_end(&self, buf: &mut Vec) -> io::Result { @@ -324,8 +324,8 @@ impl File { self.handle.write(buf) } - pub fn write_offset(&self, buf: &[u8], offset: u64) -> io::Result { - self.handle.write_offset(buf, offset) + pub fn write_at(&self, buf: &[u8], offset: u64) -> io::Result { + self.handle.write_at(buf, offset) } pub fn flush(&self) -> io::Result<()> { Ok(()) } diff --git a/src/libstd/sys/windows/handle.rs b/src/libstd/sys/windows/handle.rs index 8caf79a19d67e..98ee03fc70c6f 100644 --- a/src/libstd/sys/windows/handle.rs +++ b/src/libstd/sys/windows/handle.rs @@ -106,7 +106,7 @@ impl RawHandle { } } - pub fn read_offset(&self, buf: &mut [u8], offset: u64) -> io::Result { + pub fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result { let mut read = 0; let len = cmp::min(buf.len(), ::max_value() as usize) as c::DWORD; unsafe { @@ -189,7 +189,7 @@ impl RawHandle { Ok(amt as usize) } - pub fn write_offset(&self, buf: &[u8], offset: u64) -> io::Result { + pub fn write_at(&self, buf: &[u8], offset: u64) -> io::Result { let mut written = 0; let len = cmp::min(buf.len(), ::max_value() as usize) as c::DWORD; unsafe {