Page MenuHomePhabricator

D16275.id39147.diff
No OneTemporary

D16275.id39147.diff

diff --git a/src/filesystem/Filesystem.php b/src/filesystem/Filesystem.php
--- a/src/filesystem/Filesystem.php
+++ b/src/filesystem/Filesystem.php
@@ -251,6 +251,32 @@
/**
+ * Copy a file, preserving file attributes (if relevant for the OS).
+ *
+ * @param string File path to copy from. This file must exist and be
+ * readable, or an exception will be thrown.
+ * @param string File path to copy to. If a file exists at this path
+ * already, it wll be overwritten.
+ *
+ * @task file
+ */
+ public static function copyFile($from, $to) {
+ $from = self::resolvePath($from);
+ $to = self::resolvePath($to);
+
+ self::assertExists($from);
+ self::assertIsFile($from);
+ self::assertReadable($from);
+
+ if (phutil_is_windows()) {
+ execx('copy /Y %s %s', $from, $to);
+ } else {
+ execx('cp -p %s %s', $from, $to);
+ }
+ }
+
+
+ /**
* Remove a file or directory.
*
* @param string File to a path or directory to remove.

File Metadata

Mime Type
text/plain
Expires
Wed, Oct 23, 6:39 AM (1 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6743737
Default Alt Text
D16275.id39147.diff (1 KB)

Event Timeline