Skip to content

Commit

Permalink
preserve the file modification time when mirroring directories
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Mar 21, 2024
1 parent 26ba359 commit d232026
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Symfony/Component/Filesystem/Filesystem.php
Expand Up @@ -72,6 +72,9 @@ public function copy(string $originFile, string $targetFile, bool $overwriteNewe
// Like `cp`, preserve executable permission bits
self::box('chmod', $targetFile, fileperms($targetFile) | (fileperms($originFile) & 0111));

// Like `cp`, preserve the file modification time
self::box('touch', $targetFile, filemtime($originFile));

if ($bytesCopied !== $bytesOrigin = filesize($originFile)) {
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);
}
Expand Down

0 comments on commit d232026

Please sign in to comment.