// Write the file out to a temporary location. Prepend with a '.' to keep it
// hidden from listings and web servers.
$temporary_path =
$this->
tempnam($this->directory, '.'
);
if (!
$temporary_path || !@
file_put_contents($temporary_path,
$data)) { return FALSE;
} // The file will not be chmod() in the future so this is the final
// permission.
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