/** * Creates an object to represent a directory on the filesystem * * If multiple fDirectory objects are created for a single directory, * they will reflect changes in each other including rename and delete * actions. * * @throws fValidationException When no directory was specified, when the directory does not exist or when the path specified is not a directory * * @param string $directory The path to the directory * @param boolean $skip_checks If file checks should be skipped, which improves performance, but may cause undefined behavior - only skip these if they are duplicated elsewhere * @return fDirectory */ public function __construct($directory, $skip_checks = FALSE) { if (!$skip_checks) { if (empty($directory)) { throw new fValidationException('No directory was specified'); } if (!is_readable($directory)) { throw new fValidationException('The directory specified, %s, does not exist or is not readable', $directory); } if (!is_dir($directory)) { throw new fValidationException('The directory specified, %s, is not a directory', $directory); } } $directory = self::makeCanonical(realpath($directory)); $this->directory =& fFilesystem::hookFilenameMap($directory); $this->exception =& fFilesystem::hookExceptionMap($directory); // If there is an exception and were not inside a transaction, but we've // gotten to here, then the directory exists, so the exception must be outdated if ($this->exception !== NULL && !fFilesystem::isInsideTransaction()) { fFilesystem::updateExceptionMap($directory, NULL); } }
/** * Re-inserts the file back into the filesystem map when unserialized * * @internal * * @return void */ public function __wakeup() { $file = $this->file; $exception = $this->exception; $this->file =& fFilesystem::hookFilenameMap($file); $this->exception =& fFilesystem::hookExceptionMap($file); if ($exception !== NULL) { fFilesystem::updateExceptionMap($file, $exception); } }