aboutsummaryrefslogtreecommitdiff
path: root/docs/guides/write-file/file-cp.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/guides/write-file/file-cp.md')
-rw-r--r--docs/guides/write-file/file-cp.md16
1 files changed, 16 insertions, 0 deletions
diff --git a/docs/guides/write-file/file-cp.md b/docs/guides/write-file/file-cp.md
new file mode 100644
index 000000000..b8910e269
--- /dev/null
+++ b/docs/guides/write-file/file-cp.md
@@ -0,0 +1,16 @@
+---
+name: Copy a file to another location
+---
+
+This code snippet copies a file to another location on disk.
+
+It uses the fast [`Bun.write()`](/docs/api/file-io#writing-files-bun-write) API to efficiently write data to disk. The first argument is a _destination_, like an absolute path or `BunFile` instance. The second argument is the _data_ to write.
+
+```ts
+const file = Bun.file("/path/to/original.txt");
+await Bun.write("/path/to/copy.txt", file);
+```
+
+---
+
+See [Docs > API > File I/O](/docs/api/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`.