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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
d5673968
Commit
d5673968
authored
Jul 11, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enhanced file options for FileHelper.
parent
7c41ac99
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
11 deletions
+17
-11
FileHelper.php
framework/yii/helpers/base/FileHelper.php
+17
-11
No files found.
framework/yii/helpers/base/FileHelper.php
View file @
d5673968
...
...
@@ -10,6 +10,7 @@
namespace
yii\helpers\base
;
use
Yii
;
use
yii\helpers\StringHelper
as
StringHelper2
;
/**
* Filesystem helper
...
...
@@ -137,10 +138,11 @@ class FileHelper
* If the callback returns false, then the sub-directory or file will not be copied.
* The signature of the callback should be: `function ($path)`, where `$path` refers the full path to be copied.
* - only: array, list of patterns that the files or directories should match if they want to be copied.
* A path matches a pattern if it contains the pattern string at its end. For example,
* '/a/b' will match all files and directories ending with '/a/b'; and the '.svn' will match all files and
* directories whose name ends with '.svn'. Note, the '/' characters in a pattern matches both '/' and '\'.
* If a file/directory matches a pattern in both "only" and "except", it will NOT be copied.
* A path matches a pattern if it contains the pattern string at its end.
* Patterns ending with '/' apply to directory paths only, and patterns not ending with '/'
* apply to file paths only. For example, '/a/b' matches all file paths ending with '/a/b';
* and '.svn/' matches directory paths ending with '.svn'. Note, the '/' characters in a pattern matches
* both '/' and '\' in the paths. If a file/directory matches a pattern in both in "only" and "except", it will NOT be returned.
* - except: array, list of patterns that the files or directories should NOT match if they want to be copied.
* For more details on how to specify the patterns, please refer to the "only" option.
* - recursive: boolean, whether the files under the subdirectories should also be copied. Defaults to true.
...
...
@@ -211,10 +213,11 @@ class FileHelper
* If the callback returns false, then the sub-directory or file will be excluded from the returning result.
* The signature of the callback should be: `function ($path)`, where `$path` refers the full path to be filtered.
* - only: array, list of patterns that the files or directories should match if they want to be returned.
* A path matches a pattern if it contains the pattern string at its end. For example,
* '/a/b' will match all files and directories ending with '/a/b'; and the '.svn' will match all files and
* directories whose name ends with '.svn'. Note, the '/' characters in a pattern matches both '/' and '\'.
* If a file/directory matches a pattern in both in "only" and "except", it will NOT be returned.
* A path matches a pattern if it contains the pattern string at its end.
* Patterns ending with '/' apply to directory paths only, and patterns not ending with '/'
* apply to file paths only. For example, '/a/b' matches all file paths ending with '/a/b';
* and '.svn/' matches directory paths ending with '.svn'. Note, the '/' characters in a pattern matches
* both '/' and '\' in the paths. If a file/directory matches a pattern in both in "only" and "except", it will NOT be returned.
* - except: array, list of patterns that the files or directories should NOT match if they want to be returned.
* For more details on how to specify the patterns, please refer to the "only" option.
* - recursive: boolean, whether the files under the subdirectories should also be looked for. Defaults to true.
...
...
@@ -254,17 +257,20 @@ class FileHelper
return
false
;
}
$path
=
str_replace
(
'\\'
,
'/'
,
$path
);
$n
=
\yii\helpers\StringHelper
::
strlen
(
$path
);
if
(
is_dir
(
$path
))
{
$path
.=
'/'
;
}
$n
=
StringHelper2
::
strlen
(
$path
);
if
(
!
empty
(
$options
[
'except'
]))
{
foreach
(
$options
[
'except'
]
as
$name
)
{
if
(
\yii\helpers\StringHelper
::
substr
(
$path
,
-
\yii\helpers\StringHelper
::
strlen
(
$name
),
$n
)
===
$name
)
{
if
(
StringHelper2
::
substr
(
$path
,
-
StringHelper2
::
strlen
(
$name
),
$n
)
===
$name
)
{
return
false
;
}
}
}
if
(
!
empty
(
$options
[
'only'
]))
{
foreach
(
$options
[
'only'
]
as
$name
)
{
if
(
\yii\helpers\StringHelper
::
substr
(
$path
,
-
\yii\helpers\StringHelper
::
strlen
(
$name
),
$n
)
!==
$name
)
{
if
(
StringHelper2
::
substr
(
$path
,
-
StringHelper2
::
strlen
(
$name
),
$n
)
!==
$name
)
{
return
false
;
}
}
...
...
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