Struct inapi::File
[−]
[src]
pub struct File { /* fields omitted */ }
Primitive for managing files.
Examples
Initialise a new Host:
let mut host = Host::connect("hosts/myhost.json").unwrap();
Now you can manage a file on your managed host.
let file = File::new(&mut host, "/path/to/destination_file").unwrap(); file.upload(&mut host, "/path/to/local_file", None); file.set_owner(&mut host, "MyUser", "MyGroup").unwrap(); file.set_mode(&mut host, 644).unwrap(); // Now let's upload another file and backup the original file.upload(&mut host, "/path/to/new_file", Some(&[ FileOptions::BackupExisting("_bk".to_string()) ])).unwrap(); // Your remote path now has two entries: // "/path/to/destination_file" and "/path/to/destination_file_bk"
Methods
impl File
[src]
fn new<P: AsRef<Path>>(host: &mut Host, path: P) -> Result<File, Error>
[src]
Create a new File struct.
fn exists(&self, host: &mut Host) -> Result<bool, Error>
[src]
Check if the file exists.
fn upload<P: AsRef<Path>>(
&self,
host: &mut Host,
local_path: P,
options: Option<&[FileOptions]>
) -> Result<(), Error>
[src]
&self,
host: &mut Host,
local_path: P,
options: Option<&[FileOptions]>
) -> Result<(), Error>
Upload a file to the managed host.
fn upload_file(
&self,
host: &mut Host,
file: File,
options: Option<&[FileOptions]>
) -> Result<(), Error>
[src]
&self,
host: &mut Host,
file: File,
options: Option<&[FileOptions]>
) -> Result<(), Error>
Upload a file handle to the managed host.
fn delete(&self, host: &mut Host) -> Result<(), Error>
[src]
Delete the file.
fn mv<P: AsRef<Path>>(
&mut self,
host: &mut Host,
new_path: P
) -> Result<(), Error>
[src]
&mut self,
host: &mut Host,
new_path: P
) -> Result<(), Error>
Move the file to a new path.
fn copy<P: AsRef<Path>>(
&self,
host: &mut Host,
new_path: P
) -> Result<(), Error>
[src]
&self,
host: &mut Host,
new_path: P
) -> Result<(), Error>
Copy the file to a new path.
fn get_owner(&self, host: &mut Host) -> Result<FileOwner, Error>
[src]
Get the file's owner.
fn set_owner(
&self,
host: &mut Host,
user: &str,
group: &str
) -> Result<(), Error>
[src]
&self,
host: &mut Host,
user: &str,
group: &str
) -> Result<(), Error>
Set the file's owner.
fn get_mode(&self, host: &mut Host) -> Result<u16, Error>
[src]
Get the file's permissions mask.
fn set_mode(&self, host: &mut Host, mode: u16) -> Result<(), Error>
[src]
Set the file's permissions mask.