chmod($temporary_path, 0444
);
// Determine the exact modification time of the file.
$mtime =
$this->
getUncachedMTime($temporary_path);
// Move the temporary file into the proper directory. Note that POSIX
// compliant systems as well as modern Windows perform the rename operation
// atomically, i.e. there is no point at which another process attempting to
// access the new path will find it missing.
$directory =
$this->
getContainingDirectoryFullPath($name);
$this->
ensureDirectory($directory);
$full_path =
$this->
getFullPath($name,
$directory,
$mtime);
$result =
rename($temporary_path,
$full_path);
// Finally reset the modification time of the directory to match the one of
// the newly created file. In order to prevent the creation of a file if the
// directory does not exist, ensure that the path terminates with a
// directory separator.
//
// Recall that when subsequently loading the file, the hash is calculated
// based on the file name, the containing mtime, and a the secret string.
// Hence updating the mtime here is comparable to pointing a symbolic link
// at a new target, i.e., the newly created file.