mod builder;
mod raw;
mod win;
pub use builder::RawFileBuilder;
pub use raw::RawFile;
use std::path::Path;
use crate::Result;
use crate::security::{
ApplyMode, DescriptorEditResult, PermissionEditPlan, PermissionTarget, SecurityDescriptor,
};
pub fn raw_copy<P: AsRef<Path>, Q: AsRef<Path>>(source: P, destination: Q) -> Result<()> {
let raw = RawFile::open(source)?;
raw.copy_to(destination)
}
pub fn builder() -> RawFileBuilder {
RawFileBuilder::new()
}
pub fn read_security_descriptor<P: AsRef<Path>>(path: P) -> Result<SecurityDescriptor> {
let target = PermissionTarget::file(path.as_ref().to_string_lossy().to_string());
target.read_descriptor()
}
pub fn write_security_descriptor<P: AsRef<Path>>(
path: P,
descriptor: &SecurityDescriptor,
) -> Result<()> {
let target = PermissionTarget::file(path.as_ref().to_string_lossy().to_string());
target.write_descriptor(descriptor)
}
pub fn apply_permissions<P: AsRef<Path>>(
path: P,
plan: &PermissionEditPlan,
mode: ApplyMode,
) -> Result<DescriptorEditResult> {
let target = PermissionTarget::file(path.as_ref().to_string_lossy().to_string());
plan.execute_against_target(&target, mode)
}