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
6a84bfff
Commit
6a84bfff
authored
Jan 20, 2014
by
John Was
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored flag names
parent
86b4c4ee
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
13 deletions
+13
-13
BaseFileHelper.php
framework/helpers/BaseFileHelper.php
+13
-13
No files found.
framework/helpers/BaseFileHelper.php
View file @
6a84bfff
...
@@ -23,10 +23,10 @@ use yii\base\InvalidParamException;
...
@@ -23,10 +23,10 @@ use yii\base\InvalidParamException;
*/
*/
class
BaseFileHelper
class
BaseFileHelper
{
{
const
EXC
_FLAG_NODIR
=
1
;
const
PATTERN
_FLAG_NODIR
=
1
;
const
EXC
_FLAG_ENDSWITH
=
4
;
const
PATTERN
_FLAG_ENDSWITH
=
4
;
const
EXC
_FLAG_MUSTBEDIR
=
8
;
const
PATTERN
_FLAG_MUSTBEDIR
=
8
;
const
EXC
_FLAG_NEGATIVE
=
16
;
const
PATTERN
_FLAG_NEGATIVE
=
16
;
/**
/**
* Normalizes a file/directory path.
* Normalizes a file/directory path.
...
@@ -318,13 +318,13 @@ class BaseFileHelper
...
@@ -318,13 +318,13 @@ class BaseFileHelper
if
(
!
empty
(
$options
[
'except'
]))
{
if
(
!
empty
(
$options
[
'except'
]))
{
if
((
$except
=
self
::
lastExcludeMatchingFromList
(
$options
[
'basePath'
],
$path
,
$options
[
'except'
]))
!==
null
)
{
if
((
$except
=
self
::
lastExcludeMatchingFromList
(
$options
[
'basePath'
],
$path
,
$options
[
'except'
]))
!==
null
)
{
return
$except
[
'flags'
]
&
self
::
EXC
_FLAG_NEGATIVE
;
return
$except
[
'flags'
]
&
self
::
PATTERN
_FLAG_NEGATIVE
;
}
}
}
}
if
(
!
is_dir
(
$path
)
&&
!
empty
(
$options
[
'only'
]))
{
if
(
!
is_dir
(
$path
)
&&
!
empty
(
$options
[
'only'
]))
{
if
((
$except
=
self
::
lastExcludeMatchingFromList
(
$options
[
'basePath'
],
$path
,
$options
[
'only'
]))
!==
null
)
{
if
((
$except
=
self
::
lastExcludeMatchingFromList
(
$options
[
'basePath'
],
$path
,
$options
[
'only'
]))
!==
null
)
{
// don't check
EXC
_FLAG_NEGATIVE since those entries are not prefixed with !
// don't check
PATTERN
_FLAG_NEGATIVE since those entries are not prefixed with !
return
true
;
return
true
;
}
}
return
false
;
return
false
;
...
@@ -375,7 +375,7 @@ class BaseFileHelper
...
@@ -375,7 +375,7 @@ class BaseFileHelper
if
(
$pattern
===
$baseName
)
{
if
(
$pattern
===
$baseName
)
{
return
true
;
return
true
;
}
}
}
else
if
(
$flags
&
self
::
EXC
_FLAG_ENDSWITH
)
{
}
else
if
(
$flags
&
self
::
PATTERN
_FLAG_ENDSWITH
)
{
/* "*literal" matching against "fooliteral" */
/* "*literal" matching against "fooliteral" */
$n
=
StringHelper
::
byteLength
(
$pattern
);
$n
=
StringHelper
::
byteLength
(
$pattern
);
if
(
StringHelper
::
byteSubstr
(
$pattern
,
1
,
$n
)
===
StringHelper
::
byteSubstr
(
$baseName
,
-
$n
,
$n
))
{
if
(
StringHelper
::
byteSubstr
(
$pattern
,
1
,
$n
)
===
StringHelper
::
byteSubstr
(
$baseName
,
-
$n
,
$n
))
{
...
@@ -457,11 +457,11 @@ class BaseFileHelper
...
@@ -457,11 +457,11 @@ class BaseFileHelper
if
(
!
isset
(
$exclude
[
'pattern'
])
||
!
isset
(
$exclude
[
'flags'
])
||
!
isset
(
$exclude
[
'firstWildcard'
]))
{
if
(
!
isset
(
$exclude
[
'pattern'
])
||
!
isset
(
$exclude
[
'flags'
])
||
!
isset
(
$exclude
[
'firstWildcard'
]))
{
throw
new
InvalidParamException
(
'If exclude/include pattern is an array it must contain the pattern, flags and firstWildcard keys.'
);
throw
new
InvalidParamException
(
'If exclude/include pattern is an array it must contain the pattern, flags and firstWildcard keys.'
);
}
}
if
(
$exclude
[
'flags'
]
&
self
::
EXC
_FLAG_MUSTBEDIR
&&
!
is_dir
(
$path
))
{
if
(
$exclude
[
'flags'
]
&
self
::
PATTERN
_FLAG_MUSTBEDIR
&&
!
is_dir
(
$path
))
{
continue
;
continue
;
}
}
if
(
$exclude
[
'flags'
]
&
self
::
EXC
_FLAG_NODIR
)
{
if
(
$exclude
[
'flags'
]
&
self
::
PATTERN
_FLAG_NODIR
)
{
if
(
self
::
matchBasename
(
basename
(
$path
),
$exclude
[
'pattern'
],
$exclude
[
'firstWildcard'
],
$exclude
[
'flags'
]))
{
if
(
self
::
matchBasename
(
basename
(
$path
),
$exclude
[
'pattern'
],
$exclude
[
'firstWildcard'
],
$exclude
[
'flags'
]))
{
return
$exclude
;
return
$exclude
;
}
}
...
@@ -495,20 +495,20 @@ class BaseFileHelper
...
@@ -495,20 +495,20 @@ class BaseFileHelper
return
$result
;
return
$result
;
if
(
$pattern
[
0
]
==
'!'
)
{
if
(
$pattern
[
0
]
==
'!'
)
{
$result
[
'flags'
]
|=
self
::
EXC
_FLAG_NEGATIVE
;
$result
[
'flags'
]
|=
self
::
PATTERN
_FLAG_NEGATIVE
;
$pattern
=
StringHelper
::
byteSubstr
(
$pattern
,
1
,
StringHelper
::
byteLength
(
$pattern
));
$pattern
=
StringHelper
::
byteSubstr
(
$pattern
,
1
,
StringHelper
::
byteLength
(
$pattern
));
}
}
$len
=
StringHelper
::
byteLength
(
$pattern
);
$len
=
StringHelper
::
byteLength
(
$pattern
);
if
(
$len
&&
StringHelper
::
byteSubstr
(
$pattern
,
-
1
,
1
)
==
'/'
)
{
if
(
$len
&&
StringHelper
::
byteSubstr
(
$pattern
,
-
1
,
1
)
==
'/'
)
{
$pattern
=
StringHelper
::
byteSubstr
(
$pattern
,
0
,
-
1
);
$pattern
=
StringHelper
::
byteSubstr
(
$pattern
,
0
,
-
1
);
$len
--
;
$len
--
;
$result
[
'flags'
]
|=
self
::
EXC
_FLAG_MUSTBEDIR
;
$result
[
'flags'
]
|=
self
::
PATTERN
_FLAG_MUSTBEDIR
;
}
}
if
(
strpos
(
$pattern
,
'/'
)
===
false
)
if
(
strpos
(
$pattern
,
'/'
)
===
false
)
$result
[
'flags'
]
|=
self
::
EXC
_FLAG_NODIR
;
$result
[
'flags'
]
|=
self
::
PATTERN
_FLAG_NODIR
;
$result
[
'firstWildcard'
]
=
self
::
firstWildcardInPattern
(
$pattern
);
$result
[
'firstWildcard'
]
=
self
::
firstWildcardInPattern
(
$pattern
);
if
(
$pattern
[
0
]
==
'*'
&&
self
::
firstWildcardInPattern
(
StringHelper
::
byteSubstr
(
$pattern
,
1
,
StringHelper
::
byteLength
(
$pattern
)))
===
false
)
if
(
$pattern
[
0
]
==
'*'
&&
self
::
firstWildcardInPattern
(
StringHelper
::
byteSubstr
(
$pattern
,
1
,
StringHelper
::
byteLength
(
$pattern
)))
===
false
)
$result
[
'flags'
]
|=
self
::
EXC
_FLAG_ENDSWITH
;
$result
[
'flags'
]
|=
self
::
PATTERN
_FLAG_ENDSWITH
;
$result
[
'pattern'
]
=
$pattern
;
$result
[
'pattern'
]
=
$pattern
;
return
$result
;
return
$result
;
}
}
...
...
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