/** * Check whether the filesystem object exists. * * @return bool True if the filesystem object exists, false otherwise. */ public function exists() { return FilesystemObjectHelper::exists($this); }
public static function copy($source, $destination, $overwrite = false, $context = null) { // Convert $oldPath and $newPath into an absolute oldPath string, return false on failure if (($source = self::getAbsolutePath($source)) === null) { return false; } if (($destination = self::getAbsolutePath($destination)) === null) { return false; } // Make sure the old oldPath exists, and the new oldPath is valid if (!self::exists($source) || !self::isValid($destination)) { return false; } // Make sure the new oldPath may be overwritten if it already exists if (self::exists($destination) & !$overwrite) { return false; } // Check whether a symbolic link must be copied if (self::isSymbolicLink($source)) { // Delete the filesystem object that will be overwritten before copying the object if (FilesystemObjectHelper::exists($destination)) { if (FilesystemObjectHelper::delete($destination, true) <= 0) { return false; } } // Read the newPath of the symlink $link = SymbolicLink::asSymbolicLink($source); // Create the new symbolic link, and make sure it was made successfully return SymbolicLinkHelper::createSymbolicLink($link->getTarget(), $destination) !== null; } // Copy the object, return the result if ($context !== null) { return copy($source, $destination, $context); } return copy($source, $destination); }