8000 preserve the file modification time when mirroring directories · symfony/symfony@3849584 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3849584

Browse files
committed
preserve the file modification time when mirroring directories
1 parent 26ba359 commit 3849584

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ public function copy(string $originFile, string $targetFile, bool $overwriteNewe
7272
// Like `cp`, preserve executable permission bits
7373
self::box('chmod', $targetFile, fileperms($targetFile) | (fileperms($originFile) & 0111));
7474

75+
// Like `cp`, preserve the file modification time
76+
self::box('touch', $targetFile, filemtime($originFile));
77+
7578
if ($bytesCopied !== $bytesOrigin = filesize($originFile)) {
7679
throw new IOException(sprintf('Failed to copy the whole content of "%s" to "%s" (%g of %g bytes copied).', $originFile, $targetFile, $bytesCopied, $bytesOrigin), 0, null, $originFile);
7780
}
@@ -747,11 +750,6 @@ private static function assertFunctionExists(string $func): void
747750
}
748751
}
749752

750-
/**
751-
* @param mixed ...$args
752-
*
753-
* @return mixed
754-
*/
755753
private static function box(string $func, ...$args)
756754
{
757755
self::assertFunctionExists($func);

0 commit comments

Comments
 (0)
0