arcbox_computer_runtime/sandbox/
files.rs1use super::*;
10use crate::agent::DirWatch;
11use crate::file_proto::FileStatDto;
12
13impl ComputerManager {
14 pub async fn read_computer_file(&self, id: &ComputerId, path: &str) -> Result<Vec<u8>> {
16 let agent = self.require_alive_agent(id)?;
17 agent.files().read(path).await
18 }
19
20 pub async fn write_computer_file(
22 &self,
23 id: &ComputerId,
24 path: &str,
25 mode: u32,
26 data: &[u8],
27 ) -> Result<()> {
28 let agent = self.require_alive_agent(id)?;
29 agent.files().write(path, mode, data).await
30 }
31
32 pub async fn stat_computer_path(&self, id: &ComputerId, path: &str) -> Result<FileStatDto> {
35 let agent = self.require_alive_agent(id)?;
36 agent.files().stat(path).await
37 }
38
39 pub async fn list_computer_dir(&self, id: &ComputerId, path: &str) -> Result<Vec<FileStatDto>> {
42 let agent = self.require_alive_agent(id)?;
43 agent.files().list(path).await
44 }
45
46 pub async fn make_computer_dir(&self, id: &ComputerId, path: &str, mode: u32) -> Result<()> {
50 let agent = self.require_alive_agent(id)?;
51 agent.files().make_dir(path, mode).await
52 }
53
54 pub async fn remove_computer_path(
57 &self,
58 id: &ComputerId,
59 path: &str,
60 recursive: bool,
61 ) -> Result<()> {
62 let agent = self.require_alive_agent(id)?;
63 agent.files().remove(path, recursive).await
64 }
65
66 pub async fn move_computer_path(&self, id: &ComputerId, from: &str, to: &str) -> Result<()> {
68 let agent = self.require_alive_agent(id)?;
69 agent.files().rename(from, to).await
70 }
71
72 pub async fn watch_computer_dir(
75 &self,
76 id: &ComputerId,
77 path: &str,
78 recursive: bool,
79 ) -> Result<DirWatch> {
80 let agent = self.require_alive_agent(id)?;
81 agent.files().watch(path, recursive).await
82 }
83}