/** * Copy a file, or a folder and its contents * * @author Aidan Lister <*****@*****.**> * @version 1.0 * @param string $source The source * @param string $dest The destination * @return bool Returns true on success, false on failure */ function deepcopy($source, $dest) { // Simple copy for a file if (is_file($source)) { return copy($source, $dest); } // Make destination directory if (!is_dir($dest)) { mkdir($dest); } // Loop through the folder $dir = dir($source); while (false !== ($entry = $dir->read())) { // Skip pointers if ($entry == '.' || $entry == '..') { continue; } // Deep copy directories if (is_dir("{$source}/{$entry}") && $dest !== "{$source}/{$entry}") { deepcopy("{$source}/{$entry}", "{$dest}/{$entry}"); } else { copy("{$source}/{$entry}", "{$dest}/{$entry}"); } } // Clean up $dir->close(); return true; }
* PHP file-builder for TheOpenCD installer * Copyright 2004, TheOpenCD Project * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * ***************************************************************************--> <?php include 'deepcopy.php'; if (!is_dir($DistroDirOut)) { mkdir($DistroDirOut); } if (!is_dir($DistroDirOut . '/disctree/')) { mkdir($DistroDirOut . '/disctree/'); } if (!is_dir($DistroDirOut . '/programs/')) { mkdir($DistroDirOut . '/programs/'); } $source = $DistroDirIn . '/INFO_INC'; $dest = $DistroDirOut . '/disctree'; // Copy info and inc if ($DebugFlag) { echo "Copying <b>{$source}</b> to <b>{$dest}</b> ... <br> \n"; } if (!deepcopy($source, $dest)) { echo "Failed to copy {$source} "; exit; }