Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13990837
D16275.id39147.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D16275.id39147.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D16275: Add a method to copy files, preserving attributes
Attached
Detach File
Event Timeline
Log In to Comment