pub struct DebFile { /* private fields */ }
Expand description
Used in the DebPackage struct to represent files in a package’s archives.
This struct contains the file’s contents, permissions, and it’s path in the final package.
Implementations§
Source§impl DebFile
impl DebFile
Sourcepub fn from_path<F, T>(from: F, to: T) -> Result<Self>
pub fn from_path<F, T>(from: F, to: T) -> Result<Self>
Creates a DebFile from a path.
from
is a path to a file on your system that you’re trying to add to the package.
to
is where the file will go once the package is installed on a user’s system.
On Unix systems, the file’s mode will automatically be set based on from
.
On Windows, the file’s mode will be set to 33188
.
§Errors
This function will return an error if from
does not exist or can’t be read.
§Example
use deb_rust::DebFile;
use deb_rust::binary::DebPackage;
let mut package = DebPackage::new("example")
.with_file(DebFile::from_path(
"target/release/example",
"/usr/bin/example",
).unwrap());
Sourcepub fn from_buf<T>(buf: Vec<u8>, to: T) -> Self
pub fn from_buf<T>(buf: Vec<u8>, to: T) -> Self
Creates a DebFile from a buffer.
buf
is a buffer which will be added as the file’s contents.
to
is where the file will go once the package is installed on a user’s system.
The file’s mode is set to 33188. Permission’s must be managed manually.
§Example
use deb_rust::DebFile;
use deb_rust::binary::DebPackage;
let mut package = DebPackage::new("example")
.with_file(DebFile::from_buf(
"#!/usr/bin/bash\necho Hello world!"
.as_bytes()
.to_vec(),
"/usr/bin/example",
).is_exec());
Sourcepub fn is_conf(self) -> Self
pub fn is_conf(self) -> Self
Sets the file’s mode to have read/write permissions, without executable.
Sourcepub fn set_contents(self, contents: Vec<u8>) -> Self
pub fn set_contents(self, contents: Vec<u8>) -> Self
Sets the file’s contents to contents
.