/** * Prune the backup files down to keepNFiles. If $keepNFiles = -1 then don't * do anything * * @param <type> $path * @param <type> $stemName * @param <type> $keepNFiles */ public static function pruneFiles($path, $stemName, $keepNFiles, &$output) { $outcome = true; if ($keepNFiles == -1) { $output = 'No files pruned because keepNFiles parameter is -1'; } else { $searchPath = uFs::mp(array($path, $stemName)); $options = array('sort-by' => 'date', 'sort-order' => 'DESC'); $fileList = self::getListOfFiles($searchPath, $options, true); if (count($fileList) > $keepNFiles) { array_splice($fileList, 0, $keepNFiles); foreach ($fileList as $fileName) { uFs::unlink($fileName, true); } } } return $outcome; }
public static function symlink($target, $linkName, $throwException = true) { if (function_exists('symlink')) { if (is_link($linkName)) { if (readlink($linkName) != $target) { uFs::unlink($linkName, false); } } if (!self::relativeSymlink($target, $linkName)) { if ($throwException) { throw new Exception('symlink(' . $target . ',' . $linkName . ') failed.'); } else { return false; } } } else { if ($throwException) { throw new Exception('Function \'symlink\' does not exist.'); } else { return false; } } }
public function __destruct() { uFs::unlink($this->fullPath); }