public function relink($target, $link) { $this->clearstatcache(); $link = $this->absolutize($link); if (!file_exists($link)) { $this->symlink($target, $link); return; } // "touch" the existing symlink... // first create a symlink using a temporary name, linked to // the target then rename the temporary link to the final // link name, overwriting the existing link (i.e. atomic // vs. deleting existing then create new, non-atomic) $tmplink = sprintf("/tmp/%s%s", sha1($link), microtime(True)); symlink($target, $tmplink); if (!rename($tmplink, $link)) { $log = new api_log(); $log->err("Unable to rename tmplink '%s' to '%s' for target '%s' in bucket '%s'", $tmplink, $link, $target, $this->bucketName); if (file_exists($tmplink)) { unlink($tmplink); } } }
protected function getFilesUploaded() { $retval = array(); foreach ($_FILES as $key => $file) { if (strpos($key, 'File') === FALSE) { $log = new api_log(); $log->err("Invalid file uploaded: {$key}"); } else { $rendition = $key == 'File' ? '_' : str_replace('File_', '', $key); $retval[$rendition] = array('file' => $file['tmp_name'], 'filename' => $file['name']); } } return $retval; }