1 backup.file.inc | public BackupFile::open($write = FALSE, $binary = FALSE) |
Open a file for reading or writing.
File
- core/
includes/ backup/ backup.file.inc, line 100 - Contains the BackupFile class.
Class
- BackupFile
- Provides a utility object for reading and writing local backup files.
Code
public function open($write = FALSE, $binary = FALSE) {
if (!$this->handle) {
$path = $this->filepath();
// Check if the file can be read/written.
if ($write && ((file_exists($path) && !is_writable($path)) || !is_writable(dirname($path)))) {
$this->log('The file %path is not writable.', array('%path' => $path), 'error');
return FALSE;
}
if (!$write && !is_readable($path)) {
$this->log('The file %path cannot be read.', array('%path' => $path), 'error');
return FALSE;
}
// Open the file.
$mode = ($write ? "w" : "r") . ($binary ? "b" : "");
$this->handle = fopen($path, $mode);
return $this->handle;
}
return NULL;
}