use super::*;
use crate::agent::DirWatch;
use crate::file_proto::FileStatDto;
impl ComputerManager {
pub async fn read_computer_file(&self, id: &ComputerId, path: &str) -> Result<Vec<u8>> {
let agent = self.require_alive_agent(id)?;
agent.files().read(path).await
}
pub async fn write_computer_file(
&self,
id: &ComputerId,
path: &str,
mode: u32,
data: &[u8],
) -> Result<()> {
let agent = self.require_alive_agent(id)?;
agent.files().write(path, mode, data).await
}
pub async fn stat_computer_path(&self, id: &ComputerId, path: &str) -> Result<FileStatDto> {
let agent = self.require_alive_agent(id)?;
agent.files().stat(path).await
}
pub async fn list_computer_dir(&self, id: &ComputerId, path: &str) -> Result<Vec<FileStatDto>> {
let agent = self.require_alive_agent(id)?;
agent.files().list(path).await
}
pub async fn make_computer_dir(&self, id: &ComputerId, path: &str, mode: u32) -> Result<()> {
let agent = self.require_alive_agent(id)?;
agent.files().make_dir(path, mode).await
}
pub async fn remove_computer_path(
&self,
id: &ComputerId,
path: &str,
recursive: bool,
) -> Result<()> {
let agent = self.require_alive_agent(id)?;
agent.files().remove(path, recursive).await
}
pub async fn move_computer_path(&self, id: &ComputerId, from: &str, to: &str) -> Result<()> {
let agent = self.require_alive_agent(id)?;
agent.files().rename(from, to).await
}
pub async fn watch_computer_dir(
&self,
id: &ComputerId,
path: &str,
recursive: bool,
) -> Result<DirWatch> {
let agent = self.require_alive_agent(id)?;
agent.files().watch(path, recursive).await
}
}