protected function FileCache::writeFile in Plug 7
Writes a string content to file in an atomic way.
Parameters
string $filename Path to the file where to write the data.:
string $content The content to write:
Return value
bool TRUE on success, FALSE if path cannot be created, if path is not writable or an any other error.
2 calls to FileCache::writeFile()
- FilesystemCache::doSave in lib/
doctrine/ cache/ lib/ Doctrine/ Common/ Cache/ FilesystemCache.php - Puts data into the cache.
- PhpFileCache::doSave in lib/
doctrine/ cache/ lib/ Doctrine/ Common/ Cache/ PhpFileCache.php - Puts data into the cache.
File
- lib/
doctrine/ cache/ lib/ Doctrine/ Common/ Cache/ FileCache.php, line 186
Class
- FileCache
- Base file cache driver.
Namespace
Doctrine\Common\CacheCode
protected function writeFile($filename, $content) {
$filepath = pathinfo($filename, PATHINFO_DIRNAME);
if (!$this
->createPathIfNeeded($filepath)) {
return false;
}
if (!is_writable($filepath)) {
return false;
}
$tmpFile = tempnam($filepath, 'swap');
if (file_put_contents($tmpFile, $content) !== false) {
if (@rename($tmpFile, $filename)) {
@chmod($filename, 0666 & ~umask());
return true;
}
@unlink($tmpFile);
}
return false;
}