]> _ Git - cubist_util.git/commitdiff
wait #5347 @0:20
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 6 Jul 2022 11:42:34 +0000 (13:42 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 6 Jul 2022 11:42:34 +0000 (13:42 +0200)
src/Files/VirtualDirectory.php

index 81de6042a5aa164ad2464b79addc46712fb65209..013ce0129389ea6ec6f21045295793a3cd5adb9d 100644 (file)
@@ -23,7 +23,7 @@ class VirtualDirectory
         $this->_tmp = array();
     }
 
-    public function copy($from, $to)
+    public function copy($from, $to, $prepend = false)
     {
         if (!file_exists($from)) {
             throw new \Exception(sprintf('File %s doesn\'t exist (to %s)', $from, $to));
@@ -32,7 +32,11 @@ class VirtualDirectory
         if (!$realto) {
             return $this;
         }
-        $this->_copy[$realto] = $from;
+        if ($prepend) {
+            $this->_copy = array_merge([$realto => $from], $this->_copy);
+        } else {
+            $this->_copy[$realto] = $from;
+        }
         return $this;
     }
 
@@ -121,7 +125,7 @@ class VirtualDirectory
             if (!$path) {
                 continue;
             }
-            $this->copy($path, $this->relativePath($to) . '/' . ltrim($dest, '/'));
+            $this->copy($path, $this->relativePath($to) . '/' . ltrim($dest, '/'), true);
         }
     }