Clickalicious\PhpMemAdmin\BaseInstaller::xcopy PHP Method

xcopy() protected static method

Copy a file, or recursively copy a folder and its contents
Author: Benjamin Carl ([email protected])
protected static xcopy ( string $source, string $destination, mixed $permissions = 493 ) : boolean
$source string Source path
$destination string Destination path
$permissions mixed New folder creation permissions
return boolean Returns true on success, false on failure
    protected static function xcopy($source, $destination, $permissions = 0755)
    {
        // Check for symlinks
        if (is_link($source)) {
            return symlink(readlink($source), $destination);
        }
        // Simple copy for a file
        if (is_file($source)) {
            return copy($source, $destination);
        }
        // Make destination directory
        if (!is_dir($destination)) {
            mkdir($destination, $permissions);
        }
        // Loop through the folder
        $dir = dir($source);
        while (false !== ($entry = $dir->read())) {
            // Skip pointers
            if ($entry == '.' || $entry == '..') {
                continue;
            }
            // Deep copy directories
            self::xcopy($source . DIRECTORY_SEPARATOR . $entry, $destination . DIRECTORY_SEPARATOR . $entry);
        }
        // Clean up
        $dir->close();
        return true;
    }