Exemplo n.º 1
0
 /**
  * Create a directory
  */
 public function mkdir($path, $mode, $options)
 {
     if (!$this->initPath($path)) {
         return FALSE;
     }
     $recursive = $options & STREAM_MKDIR_RECURSIVE;
     $dirs = explode('/', $this->getFileName());
     $next = '';
     $dirname = '';
     $created = FALSE;
     do {
         if (!$next && $dirname) {
             continue;
         }
         $dirname .= $dirname === '/' ? $next : '/' . $next;
         if ($recursive || $dirname === '/') {
             $created = $this->fileSystem->createDirectory($dirname);
         }
         $type = $this->fileSystem->getFileType($dirname);
         if ($type !== FileSystem::FILE_TYPE_DIRECTORY) {
             if ($type !== FALSE) {
                 return FALSE;
             }
             if (!empty($dirs)) {
                 return FALSE;
             }
             $created = FALSE;
             break;
         }
     } while (($next = array_shift($dirs)) !== NULL);
     if (!$created) {
         $created = $this->fileSystem->createDirectory($dirname);
     }
     return !!$created;
 }
Exemplo n.º 2
0
 public function testCreateDirectoryCreatesDirectories()
 {
     $fs = new FileSystem();
     $directory = $fs->createDirectory('/dir/dir', true);
     $this->assertInstanceOf('\\VirtualFileSystem\\Structure\\Directory', $directory);
     $this->assertEquals('/dir/dir', $directory->path());
 }
Exemplo n.º 3
0
 public function checkFolder()
 {
     $path = $this->getFolderPath();
     if (!file_exists($path) && !FileSystem::createDirectory($path)) {
         throw new RuntimeException('Folder to store images for ' . get_class($this) . ' doesnt exist');
     }
     return true;
 }
Exemplo n.º 4
0
 public function getSavePath()
 {
     $imagePath = Yii::app()->params['blog']['imagePath'];
     if (!file_exists($imagePath)) {
         FileSystem::createDirectory($imagePath);
     }
     return $imagePath;
 }
Exemplo n.º 5
0
 public static function setDefaultLogName($addName = '', $logKey = 'default', $runFileName = '')
 {
     if (empty($addName)) {
         $fileName = DIR_LOG . Format::date() . $addName . '.log';
     } else {
         $fileName = DIR_LOG . $addName . '.log';
     }
     FileSystem::createDirectory(DIR_LOG);
     self::$_fileNames[$logKey] = $fileName;
     self::$_runFileName = $runFileName;
 }
Exemplo n.º 6
0
 public function setUp()
 {
     $pathToImages = $this->getFolderPath();
     FileSystem::createDirectory($pathToImages);
     if (file_exists($pathToImages . '/' . self::TEST_IMAGE_SMALL_NAME)) {
         $this->assertTrue(unlink($pathToImages . '/' . self::TEST_IMAGE_SMALL_NAME));
     }
     if (file_exists($pathToImages . '/' . self::TEST_IMAGE_MEDIUM_NAME)) {
         $this->assertTrue(unlink($pathToImages . '/' . self::TEST_IMAGE_MEDIUM_NAME));
     }
     $testImgName = self::TEST_IMAGE_NAME;
     $source = Yii::getPathOfAlias('application.tests.data') . '/' . $testImgName;
     $dest = $pathToImages . '/' . $testImgName;
     $this->assertTrue(copy($source, $dest), 'cannot copy ' . $source . ' to ' . $dest);
 }
Exemplo n.º 7
0
 /**
  * @param $path
  * @return bool
  * @deprecated since r1234 moved to FileSystem
  * @see        FileSystem
  */
 public static function createDirectory($path)
 {
     return FileSystem::createDirectory($path);
 }