Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function open(StreamMode $mode)
 {
     $baseDirPath = \Gaufrette\Util\Path::dirname($this->path);
     if ($mode->allowsWrite() && !is_dir($baseDirPath)) {
         @mkdir($baseDirPath, 0755, true);
     }
     try {
         $fileHandle = @fopen($this->path, $mode->getMode());
     } catch (\Exception $e) {
         $fileHandle = false;
     }
     if (false === $fileHandle) {
         throw new \RuntimeException(sprintf('File "%s" cannot be opened', $this->path));
     }
     $this->mode = $mode;
     $this->fileHandle = $fileHandle;
     return true;
 }