Piwik\Filesystem::unlinkTargetFilesNotPresentInSource PHP Method

unlinkTargetFilesNotPresentInSource() public static method

Removes all files and directories that are present in the target directory but are not in the source directory.
public static unlinkTargetFilesNotPresentInSource ( string $source, string $target )
$source string Path to the source directory
$target string Path to the target
    public static function unlinkTargetFilesNotPresentInSource($source, $target)
    {
        $diff = self::directoryDiff($source, $target);
        $diff = self::sortFilesDescByPathLength($diff);
        foreach ($diff as $file) {
            $remove = $target . $file;
            if (is_dir($remove)) {
                @rmdir($remove);
            } else {
                self::deleteFileIfExists($remove);
            }
        }
    }

Usage Example

Example #1
0
 public function removeGoneFiles($source, $target)
 {
     Filesystem::unlinkTargetFilesNotPresentInSource($source . '/core', $target . '/core');
     foreach ($this->getPluginsFromDirectoy($source) as $pluginDir) {
         Filesystem::unlinkTargetFilesNotPresentInSource($source . $pluginDir, $target . $pluginDir);
     }
 }
All Usage Examples Of Piwik\Filesystem::unlinkTargetFilesNotPresentInSource