Skip to content

Commit 1c47b0e

Browse files
add vfs.cp function
1 parent 0592337 commit 1c47b0e

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

async-vfs-os/src/os.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ impl Vfs for OsFs {
132132
Ok((list, None))
133133
}
134134

135+
async fn cp(&self, from: &str, to: &str) -> VfsResult<()> {
136+
fs::copy(self.get_real_path(from)?, self.get_real_path(to)?).await?;
137+
Ok(())
138+
}
139+
135140
async fn metadata(&self, path: &str) -> VfsResult<Box<dyn VMetadata>> {
136141
let path = self.get_real_path(path)?;
137142

async-vfs/src/vfs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ pub trait Vfs: Sync + Send {
3232
skip_token: Option<String>,
3333
) -> VfsResult<(Vec<Box<dyn VMetadata>>, Option<String>)>;
3434

35+
async fn cp(&self, from: &str, to: &str) -> VfsResult<()>;
3536
async fn metadata(&self, path: &str) -> VfsResult<Box<dyn VMetadata>>;
36-
3737
async fn mkdir(&self, path: &str) -> VfsResult<()>;
3838
async fn mv(&self, from: &str, to: &str) -> VfsResult<()>;
3939
async fn open(&self, path: &str, options: OpenOptions) -> VfsResult<Pin<Box<dyn VFile>>>;

0 commit comments

Comments
 (0)