/** * 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; }
public function testCreateDirectoryCreatesDirectories() { $fs = new FileSystem(); $directory = $fs->createDirectory('/dir/dir', true); $this->assertInstanceOf('\\VirtualFileSystem\\Structure\\Directory', $directory); $this->assertEquals('/dir/dir', $directory->path()); }
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; }
public function getSavePath() { $imagePath = Yii::app()->params['blog']['imagePath']; if (!file_exists($imagePath)) { FileSystem::createDirectory($imagePath); } return $imagePath; }
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; }
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); }
/** * @param $path * @return bool * @deprecated since r1234 moved to FileSystem * @see FileSystem */ public static function createDirectory($path) { return FileSystem::createDirectory($path); }