diff options
author | Alex Crichton <alex@alexcrichton.com> | 2015-01-28 08:11:13 -0800 |
---|---|---|
committer | Alex Crichton <alex@alexcrichton.com> | 2015-01-28 08:11:13 -0800 |
commit | 50c36039fe7cf65692acd34d5b849dbdb1caf9b2 (patch) | |
tree | d39f1bd6b641e80f68df7eda2f025ed587982242 /src | |
parent | f125dbfd31473fc5958955ac7546b06fafd04530 (diff) | |
download | ssh2-rs-50c36039fe7cf65692acd34d5b849dbdb1caf9b2.zip |
Update to rust master
Diffstat (limited to 'src')
-rw-r--r-- | src/channel.rs | 22 | ||||
-rw-r--r-- | src/lib.rs | 12 | ||||
-rw-r--r-- | src/session.rs | 26 | ||||
-rw-r--r-- | src/sftp.rs | 46 |
4 files changed, 53 insertions, 53 deletions
diff --git a/src/channel.rs b/src/channel.rs index 7dabcb8..e415af7 100644 --- a/src/channel.rs +++ b/src/channel.rs @@ -1,5 +1,5 @@ use std::cmp; -use std::io; +use std::old_io; use libc::{c_uint, c_int, size_t, c_char, c_void, c_uchar}; use {raw, Session, Error}; @@ -398,20 +398,20 @@ impl<'sess> SessionBinding<'sess> for Channel<'sess> { } impl<'sess> Writer for Channel<'sess> { - fn write(&mut self, buf: &[u8]) -> io::IoResult<()> { + fn write_all(&mut self, buf: &[u8]) -> old_io::IoResult<()> { self.write_stream(0, buf).map_err(|e| { - io::IoError { - kind: io::OtherIoError, + old_io::IoError { + kind: old_io::OtherIoError, desc: "ssh write error", detail: Some(e.to_string()), } }) } - fn flush(&mut self) -> io::IoResult<()> { + fn flush(&mut self) -> old_io::IoResult<()> { self.flush_stream(0).map_err(|e| { - io::IoError { - kind: io::OtherIoError, + old_io::IoError { + kind: old_io::OtherIoError, desc: "ssh write error", detail: Some(e.to_string()), } @@ -420,13 +420,13 @@ impl<'sess> Writer for Channel<'sess> { } impl<'sess> Reader for Channel<'sess> { - fn read(&mut self, buf: &mut [u8]) -> io::IoResult<usize> { + fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<usize> { self.read_stream(0, buf).map_err(|e| { if self.eof() { - io::standard_error(io::EndOfFile) + old_io::standard_error(old_io::EndOfFile) } else { - io::IoError { - kind: io::OtherIoError, + old_io::IoError { + kind: old_io::OtherIoError, desc: "ssh read error", detail: Some(e.to_string()), } @@ -32,7 +32,7 @@ //! ## Authenticating with ssh-agent //! //! ```no_run -//! use std::io::TcpStream; +//! use std::old_io::TcpStream; //! use ssh2::Session; //! //! // Connect to the local SSH server @@ -50,7 +50,7 @@ //! ## Authenticating with a password //! //! ```no_run -//! use std::io::TcpStream; +//! use std::old_io::TcpStream; //! use ssh2::Session; //! //! // Connect to the local SSH server @@ -65,7 +65,7 @@ //! ## Run a command //! //! ```no_run -//! use std::io::{self, TcpStream}; +//! use std::old_io::{self, TcpStream}; //! use ssh2::Session; //! //! // Connect to the local SSH server @@ -83,7 +83,7 @@ //! ## Upload a file //! //! ```no_run -//! use std::io::{self, TcpStream}; +//! use std::old_io::{self, TcpStream}; //! use ssh2::Session; //! //! // Connect to the local SSH server @@ -93,14 +93,14 @@ //! sess.userauth_agent("username").unwrap(); //! //! let mut remote_file = sess.scp_send(&Path::new("remote"), -//! io::USER_FILE, 10, None).unwrap(); +//! old_io::USER_FILE, 10, None).unwrap(); //! remote_file.write(b"1234567890").unwrap(); //! ``` //! //! ## Download a file //! //! ```no_run -//! use std::io::TcpStream; +//! use std::old_io::TcpStream; //! use ssh2::Session; //! //! // Connect to the local SSH server diff --git a/src/session.rs b/src/session.rs index fe96993..c4ea9ec 100644 --- a/src/session.rs +++ b/src/session.rs @@ -1,5 +1,5 @@ use std::ffi::CString; -use std::io::{self, TcpStream}; +use std::old_io::{self, TcpStream}; use std::mem; use std::slice; use std::str; @@ -406,7 +406,7 @@ impl Session { /// sent over the returned channel. Some stat information is also returned /// about the remote file to prepare for receiving the file. pub fn scp_recv(&self, path: &Path) - -> Result<(Channel, io::FileStat), Error> { + -> Result<(Channel, old_io::FileStat), Error> { let path = CString::from_slice(path.as_vec()); unsafe { let mut sb: libc::stat = mem::zeroed(); @@ -431,7 +431,7 @@ impl Session { /// /// The size of the file, `size`, must be known ahead of time before /// transmission. - pub fn scp_send(&self, remote_path: &Path, mode: io::FilePermission, + pub fn scp_send(&self, remote_path: &Path, mode: old_io::FilePermission, size: u64, times: Option<(u64, u64)>) -> Result<Channel, Error> { let path = CString::from_slice(remote_path.as_vec()); @@ -611,7 +611,7 @@ impl Binding for Session { } // Sure do wish this was exported in libnative! -fn mkstat(stat: &libc::stat) -> io::FileStat { +fn mkstat(stat: &libc::stat) -> old_io::FileStat { #[cfg(windows)] type Mode = libc::c_int; #[cfg(unix)] type Mode = libc::mode_t; @@ -628,21 +628,21 @@ fn mkstat(stat: &libc::stat) -> io::FileStat { #[cfg(any(target_os = "linux", target_os = "android"))] fn gen(_stat: &libc::stat) -> u64 { 0 } - io::FileStat { + old_io::FileStat { size: stat.st_size as u64, kind: match (stat.st_mode as Mode) & libc::S_IFMT { - libc::S_IFREG => io::FileType::RegularFile, - libc::S_IFDIR => io::FileType::Directory, - libc::S_IFIFO => io::FileType::NamedPipe, - libc::S_IFBLK => io::FileType::BlockSpecial, - libc::S_IFLNK => io::FileType::Symlink, - _ => io::FileType::Unknown, + libc::S_IFREG => old_io::FileType::RegularFile, + libc::S_IFDIR => old_io::FileType::Directory, + libc::S_IFIFO => old_io::FileType::NamedPipe, + libc::S_IFBLK => old_io::FileType::BlockSpecial, + libc::S_IFLNK => old_io::FileType::Symlink, + _ => old_io::FileType::Unknown, }, - perm: io::FilePermission::from_bits_truncate(stat.st_mode as u32), + perm: old_io::FilePermission::from_bits_truncate(stat.st_mode as u32), created: mktime(stat.st_ctime as u64, stat.st_ctime_nsec as u64), modified: mktime(stat.st_mtime as u64, stat.st_mtime_nsec as u64), accessed: mktime(stat.st_atime as u64, stat.st_atime_nsec as u64), - unstable: io::UnstableFileStat { + unstable: old_io::UnstableFileStat { device: stat.st_dev as u64, inode: stat.st_ino as u64, rdev: stat.st_rdev as u64, diff --git a/src/sftp.rs b/src/sftp.rs index ec9dd39..038917a 100644 --- a/src/sftp.rs +++ b/src/sftp.rs @@ -1,6 +1,6 @@ use std::marker; use std::mem; -use std::io; +use std::old_io; use libc::{c_int, c_ulong, c_long, c_uint, size_t}; use {raw, Session, Error}; @@ -16,7 +16,7 @@ pub struct Sftp<'sess> { /// A file handle to an SFTP connection. /// -/// Files behave similarly to `std::io::File` in that they are readable and +/// Files behave similarly to `std::old_io::File` in that they are readable and /// writable and support operations like stat and seek. /// /// Files are created through `open`, `create`, and `open_mode` on an instance @@ -98,7 +98,7 @@ pub enum OpenType { impl<'sess> Sftp<'sess> { /// Open a handle to a file. pub fn open_mode(&self, filename: &Path, flags: OpenFlags, - mode: io::FilePermission, + mode: old_io::FilePermission, open_type: OpenType) -> Result<File, Error> { let filename = filename.as_vec(); unsafe { @@ -118,17 +118,17 @@ impl<'sess> Sftp<'sess> { /// Helper to open a file in the `Read` mode. pub fn open(&self, filename: &Path) -> Result<File, Error> { - self.open_mode(filename, READ, io::USER_FILE, OpenType::File) + self.open_mode(filename, READ, old_io::USER_FILE, OpenType::File) } /// Helper to create a file in write-only mode with truncation. pub fn create(&self, filename: &Path) -> Result<File, Error> { - self.open_mode(filename, WRITE | TRUNCATE, io::USER_FILE, OpenType::File) + self.open_mode(filename, WRITE | TRUNCATE, old_io::USER_FILE, OpenType::File) } /// Helper to open a directory for reading its contents. pub fn opendir(&self, dirname: &Path) -> Result<File, Error> { - self.open_mode(dirname, READ, io::USER_FILE, OpenType::Dir) + self.open_mode(dirname, READ, old_io::USER_FILE, OpenType::Dir) } /// Convenience function to read the files in a directory. @@ -155,7 +155,7 @@ impl<'sess> Sftp<'sess> { } /// Create a directory on the remote file system. - pub fn mkdir(&self, filename: &Path, mode: io::FilePermission) + pub fn mkdir(&self, filename: &Path, mode: old_io::FilePermission) -> Result<(), Error> { let filename = filename.as_vec(); self.rc(unsafe { @@ -419,15 +419,15 @@ impl<'sftp> File<'sftp> { } impl<'sftp> Reader for File<'sftp> { - fn read(&mut self, buf: &mut [u8]) -> io::IoResult<usize> { + fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<usize> { unsafe { let rc = raw::libssh2_sftp_read(self.raw, buf.as_mut_ptr() as *mut _, buf.len() as size_t); match rc { - 0 => Err(io::standard_error(io::EndOfFile)), - n if n < 0 => Err(io::IoError { - kind: io::OtherIoError, + 0 => Err(old_io::standard_error(old_io::EndOfFile)), + n if n < 0 => Err(old_io::IoError { + kind: old_io::OtherIoError, desc: "read error", detail: Some(self.sftp.last_error().to_string()), }), @@ -438,7 +438,7 @@ impl<'sftp> Reader for File<'sftp> { } impl<'sftp> Writer for File<'sftp> { - fn write(&mut self, mut buf: &[u8]) -> io::IoResult<()> { + fn write_all(&mut self, mut buf: &[u8]) -> old_io::IoResult<()> { while buf.len() > 0 { let rc = unsafe { raw::libssh2_sftp_write(self.raw, @@ -446,8 +446,8 @@ impl<'sftp> Writer for File<'sftp> { buf.len() as size_t) }; if rc < 0 { - return Err(io::IoError { - kind: io::OtherIoError, + return Err(old_io::IoError { + kind: old_io::OtherIoError, desc: "write error", detail: Some(self.sftp.last_error().to_string()), }) @@ -459,7 +459,7 @@ impl<'sftp> Writer for File<'sftp> { } impl<'sftp> Seek for File<'sftp> { - fn tell(&self) -> io::IoResult<u64> { + fn tell(&self) -> old_io::IoResult<u64> { Ok(unsafe { raw::libssh2_sftp_tell64(self.raw) }) } @@ -473,21 +473,21 @@ impl<'sftp> Seek for File<'sftp> { /// You MUST NOT seek during writing or reading a file with SFTP, as the /// internals use outstanding packets and changing the "file position" /// during transit will results in badness. - fn seek(&mut self, offset: i64, whence: io::SeekStyle) -> io::IoResult<()> { + fn seek(&mut self, offset: i64, whence: old_io::SeekStyle) -> old_io::IoResult<()> { let next = match whence { - io::SeekSet => offset as u64, - io::SeekCur => (self.tell().unwrap() as i64 + offset) as u64, - io::SeekEnd => match self.stat() { + old_io::SeekSet => offset as u64, + old_io::SeekCur => (self.tell().unwrap() as i64 + offset) as u64, + old_io::SeekEnd => match self.stat() { Ok(s) => match s.size { Some(size) => (size as i64 + offset) as u64, - None => return Err(io::IoError { - kind: io::OtherIoError, + None => return Err(old_io::IoError { + kind: old_io::OtherIoError, desc: "no file size available", detail: None, }) }, - Err(e) => return Err(io::IoError { - kind: io::OtherIoError, + Err(e) => return Err(old_io::IoError { + kind: old_io::OtherIoError, desc: "failed to stat remote file", detail: Some(e.to_string()), }), |