コード例 #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;
 }
コード例 #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());
 }
コード例 #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;
 }
コード例 #4
0
ファイル: BlogImage.php プロジェクト: jankichaudhari/yii-site
 public function getSavePath()
 {
     $imagePath = Yii::app()->params['blog']['imagePath'];
     if (!file_exists($imagePath)) {
         FileSystem::createDirectory($imagePath);
     }
     return $imagePath;
 }
コード例 #5
0
ファイル: Logger.php プロジェクト: binocchi/my_snippet
 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;
 }
コード例 #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);
 }
コード例 #7
0
ファイル: Util.php プロジェクト: jankichaudhari/yii-site
 /**
  * @param $path
  * @return bool
  * @deprecated since r1234 moved to FileSystem
  * @see        FileSystem
  */
 public static function createDirectory($path)
 {
     return FileSystem::createDirectory($path);
 }