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
e11ce600
Commit
e11ce600
authored
Jul 11, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed the "only" option for FileHelper::findFiles()
parent
0cbb05d7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
10 deletions
+18
-10
FileHelper.php
framework/yii/helpers/base/FileHelper.php
+18
-10
No files found.
framework/yii/helpers/base/FileHelper.php
View file @
e11ce600
...
@@ -142,14 +142,17 @@ class FileHelper
...
@@ -142,14 +142,17 @@ class FileHelper
* * false: the directory or file will NOT be copied (the "only" and "except" options will be ignored)
* * false: the directory or file will NOT be copied (the "only" and "except" options will be ignored)
* * null: the "only" and "except" options will determine whether the directory or file should be copied
* * null: the "only" and "except" options will determine whether the directory or file should be copied
*
*
* - only: array, list of patterns that the files or directories should match if they want to be copied.
* - only: array, list of patterns that the file paths should match if they want to be copied.
* A path matches a pattern if it contains the pattern string at its end.
* For example, '.php' matches all file paths ending with '.php'.
* Note, the '/' characters in a pattern matches both '/' and '\' in the paths.
* If a file path matches a pattern in both "only" and "except", it will NOT be copied.
* - except: array, list of patterns that the files or directories should match if they want to be excluded from being copied.
* A path matches a pattern if it contains the pattern string at its end.
* 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 '/'
* 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';
* 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
* 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.
* both '/' and '\' in the paths.
* - 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.
* - recursive: boolean, whether the files under the subdirectories should also be copied. Defaults to true.
* - afterCopy: callback, a PHP callback that is called after each sub-directory or file is successfully copied.
* - afterCopy: callback, a PHP callback that is called after each sub-directory or file is successfully copied.
* The signature of the callback should be: `function ($from, $to)`, where `$from` is the sub-directory or
* The signature of the callback should be: `function ($from, $to)`, where `$from` is the sub-directory or
...
@@ -222,14 +225,17 @@ class FileHelper
...
@@ -222,14 +225,17 @@ class FileHelper
* * false: the directory or file will NOT be returned (the "only" and "except" options will be ignored)
* * false: the directory or file will NOT be returned (the "only" and "except" options will be ignored)
* * null: the "only" and "except" options will determine whether the directory or file should be returned
* * null: the "only" and "except" options will determine whether the directory or file should be returned
*
*
* - only: array, list of patterns that the files or directories should match if they want to be returned.
* - only: array, list of patterns that the file paths should match if they want to be returned.
* A path matches a pattern if it contains the pattern string at its end.
* For example, '.php' matches all file paths ending with '.php'.
* Note, the '/' characters in a pattern matches both '/' and '\' in the paths.
* If a file path matches a pattern in both "only" and "except", it will NOT be returned.
* - except: array, list of patterns that the file paths or directory paths should match if they want to be excluded from the result.
* A path matches a pattern if it contains the pattern string at its end.
* 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 '/'
* 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';
* 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
* 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.
* both '/' and '\' in the paths.
* - 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.
* - recursive: boolean, whether the files under the subdirectories should also be looked for. Defaults to true.
* @return array files found under the directory. The file list is sorted.
* @return array files found under the directory. The file list is sorted.
*/
*/
...
@@ -270,10 +276,11 @@ class FileHelper
...
@@ -270,10 +276,11 @@ class FileHelper
}
}
}
}
$path
=
str_replace
(
'\\'
,
'/'
,
$path
);
$path
=
str_replace
(
'\\'
,
'/'
,
$path
);
if
(
is_dir
(
$path
))
{
if
(
$isDir
=
is_dir
(
$path
))
{
$path
.=
'/'
;
$path
.=
'/'
;
}
}
$n
=
StringHelper2
::
strlen
(
$path
);
$n
=
StringHelper2
::
strlen
(
$path
);
if
(
!
empty
(
$options
[
'except'
]))
{
if
(
!
empty
(
$options
[
'except'
]))
{
foreach
(
$options
[
'except'
]
as
$name
)
{
foreach
(
$options
[
'except'
]
as
$name
)
{
if
(
StringHelper2
::
substr
(
$path
,
-
StringHelper2
::
strlen
(
$name
),
$n
)
===
$name
)
{
if
(
StringHelper2
::
substr
(
$path
,
-
StringHelper2
::
strlen
(
$name
),
$n
)
===
$name
)
{
...
@@ -281,7 +288,8 @@ class FileHelper
...
@@ -281,7 +288,8 @@ class FileHelper
}
}
}
}
}
}
if
(
!
empty
(
$options
[
'only'
]))
{
if
(
!
$isDir
&&
!
empty
(
$options
[
'only'
]))
{
foreach
(
$options
[
'only'
]
as
$name
)
{
foreach
(
$options
[
'only'
]
as
$name
)
{
if
(
StringHelper2
::
substr
(
$path
,
-
StringHelper2
::
strlen
(
$name
),
$n
)
===
$name
)
{
if
(
StringHelper2
::
substr
(
$path
,
-
StringHelper2
::
strlen
(
$name
),
$n
)
===
$name
)
{
return
true
;
return
true
;
...
...
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