use super::*;
use crate::agent::DirWatch;
use crate::file_proto::FileStatDto;
impl SandboxManager {
pub async fn read_sandbox_file(&self, id: &SandboxId, path: &str) -> Result<Vec<u8>> {
let agent = self.require_alive_agent(id)?;
agent.files().read(path).await
}
pub async fn write_sandbox_file(
&self,
id: &SandboxId,
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_sandbox_path(&self, id: &SandboxId, path: &str) -> Result<FileStatDto> {
let agent = self.require_alive_agent(id)?;
agent.files().stat(path).await
}
pub async fn list_sandbox_dir(&self, id: &SandboxId, path: &str) -> Result<Vec<FileStatDto>> {
let agent = self.require_alive_agent(id)?;
agent.files().list(path).await
}
pub async fn make_sandbox_dir(&self, id: &SandboxId, path: &str, mode: u32) -> Result<()> {
let agent = self.require_alive_agent(id)?;
agent.files().make_dir(path, mode).await
}
pub async fn remove_sandbox_path(
&self,
id: &SandboxId,
path: &str,
recursive: bool,
) -> Result<()> {
let agent = self.require_alive_agent(id)?;
agent.files().remove(path, recursive).await
}
pub async fn move_sandbox_path(&self, id: &SandboxId, from: &str, to: &str) -> Result<()> {
let agent = self.require_alive_agent(id)?;
agent.files().rename(from, to).await
}
pub async fn watch_sandbox_dir(
&self,
id: &SandboxId,
path: &str,
recursive: bool,
) -> Result<DirWatch> {
let agent = self.require_alive_agent(id)?;
agent.files().watch(path, recursive).await
}
}