Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
8f7a7837
Commit
8f7a7837
authored
Jun 10, 2013
by
Klimov Paul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Method "yii\helpers\base\FileHelper::mkdir()" has been added.
parent
f416a366
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
+35
-0
FileHelper.php
framework/yii/helpers/base/FileHelper.php
+22
-0
FileHelperTest.php
tests/unit/framework/helpers/FileHelperTest.php
+13
-0
No files found.
framework/yii/helpers/base/FileHelper.php
View file @
8f7a7837
...
@@ -288,4 +288,26 @@ class FileHelper
...
@@ -288,4 +288,26 @@ class FileHelper
return
false
;
return
false
;
}
}
}
}
/**
* Shared environment safe version of mkdir. Supports recursive creation.
* For avoidance of umask side-effects chmod is used.
*
* @param string $path path to be created.
* @param integer $mode the permission to be set for created directory. If not set 0777 will be used.
* @param boolean $recursive whether to create directory structure recursive if parent dirs do not exist.
* @return boolean result of mkdir.
* @see mkdir
*/
public
static
function
mkdir
(
$path
,
$mode
=
null
,
$recursive
=
false
)
{
$prevDir
=
dirname
(
$path
);
if
(
$recursive
&&
!
is_dir
(
$path
)
&&
!
is_dir
(
$prevDir
))
{
static
::
mkdir
(
dirname
(
$path
),
$mode
,
true
);
}
$mode
=
isset
(
$mode
)
?
$mode
:
0777
;
$result
=
mkdir
(
$path
,
$mode
);
chmod
(
$path
,
$mode
);
return
$result
;
}
}
}
tests/unit/framework/helpers/FileHelperTest.php
View file @
8f7a7837
...
@@ -266,4 +266,16 @@ class FileHelperTest extends TestCase
...
@@ -266,4 +266,16 @@ class FileHelperTest extends TestCase
$foundFiles
=
FileHelper
::
findFiles
(
$dirName
,
$options
);
$foundFiles
=
FileHelper
::
findFiles
(
$dirName
,
$options
);
$this
->
assertEquals
(
array
(
$dirName
.
DIRECTORY_SEPARATOR
.
$fileName
),
$foundFiles
);
$this
->
assertEquals
(
array
(
$dirName
.
DIRECTORY_SEPARATOR
.
$fileName
),
$foundFiles
);
}
}
public
function
testMkdir
()
{
$basePath
=
$this
->
testFilePath
;
$dirName
=
$basePath
.
DIRECTORY_SEPARATOR
.
'test_dir'
;
FileHelper
::
mkdir
(
$dirName
);
$this
->
assertTrue
(
file_exists
(
$dirName
),
'Unable to create directory!'
);
$dirName
=
$basePath
.
DIRECTORY_SEPARATOR
.
'test_dir_level_1'
.
DIRECTORY_SEPARATOR
.
'test_dir_level_2'
;
FileHelper
::
mkdir
(
$dirName
,
null
,
true
);
$this
->
assertTrue
(
file_exists
(
$dirName
),
'Unable to create directory recursively!'
);
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment