本文整理汇总了PHP中FileSystem::createDirectory方法的典型用法代码示例。如果您正苦于以下问题:PHP FileSystem::createDirectory方法的具体用法?PHP FileSystem::createDirectory怎么用?PHP FileSystem::createDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileSystem
的用法示例。
在下文中一共展示了FileSystem::createDirectory方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mkdir
/**
* 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: testCreateDirectoryCreatesDirectories
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: checkFolder
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: getSavePath
public function getSavePath()
{
$imagePath = Yii::app()->params['blog']['imagePath'];
if (!file_exists($imagePath)) {
FileSystem::createDirectory($imagePath);
}
return $imagePath;
}
示例5: setDefaultLogName
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: setUp
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: createDirectory
/**
* @param $path
* @return bool
* @deprecated since r1234 moved to FileSystem
* @see FileSystem
*/
public static function createDirectory($path)
{
return FileSystem::createDirectory($path);
}