コード例 #1
0
ファイル: emboss.php プロジェクト: webmatter/gallery3-contrib
 private function copy_new($src, $dst)
 {
     if (!is_dir($src)) {
         return;
     }
     if (!file_exists($dst)) {
         log::info('emboss', "Creating directory {$dst}");
         if (!@mkdir($dst)) {
             emboss::error("Failed to create {$dst}");
             return;
         }
     }
     if (!is_dir($dst)) {
         emboss::error("Existing {$dst} is not a directory");
         return;
     }
     if (!($dh = opendir($src))) {
         emboss::error("Failed to open {$src} for reading");
         return;
     }
     while ($file = readdir($dh)) {
         if ($file == '.' || $file == '..') {
             continue;
         }
         $srcpath = $src . '/' . $file;
         $dstpath = $dst . '/' . $file;
         if (is_dir($srcpath)) {
             emboss::copy_new($srcpath, $dstpath);
         } else {
             if (!file_exists($dstpath)) {
                 log::info('emboss', "Copying {$file} to {$dst}");
                 if (!@copy($srcpath, $dstpath)) {
                     emboss::error("Failed to copy {$file} to {$dst}");
                 }
             }
         }
     }
     closedir($dh);
 }