Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
b7ce4523
Commit
b7ce4523
authored
Mar 07, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fs/Traits: add IsSpecialFilename()
Merge some duplicate code in a central library.
parent
5faf7605
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
13 deletions
+16
-13
InotifyUpdate.cxx
src/db/update/InotifyUpdate.cxx
+2
-2
Walk.cxx
src/db/update/Walk.cxx
+1
-1
Traits.hxx
src/fs/Traits.hxx
+12
-0
LocalStorage.cxx
src/storage/plugins/LocalStorage.cxx
+1
-10
No files found.
src/db/update/InotifyUpdate.cxx
View file @
b7ce4523
...
...
@@ -24,6 +24,7 @@
#include "storage/StorageInterface.hxx"
#include "fs/AllocatedPath.hxx"
#include "fs/FileInfo.hxx"
#include "fs/Traits.hxx"
#include "Log.hxx"
#include <string>
...
...
@@ -146,8 +147,7 @@ WatchDirectory::GetUriFS() const noexcept
/* we don't look at "." / ".." nor files with newlines in their name */
static
bool
skip_path
(
const
char
*
path
)
{
return
(
path
[
0
]
==
'.'
&&
path
[
1
]
==
0
)
||
(
path
[
0
]
==
'.'
&&
path
[
1
]
==
'.'
&&
path
[
2
]
==
0
)
||
return
PathTraitsFS
::
IsSpecialFilename
(
path
)
||
strchr
(
path
,
'\n'
)
!=
nullptr
;
}
...
...
src/db/update/Walk.cxx
View file @
b7ce4523
...
...
@@ -237,7 +237,7 @@ try {
LogError
(
std
::
current_exception
());
}
/* we don't look at
"." / ".." nor
files with newlines in their name */
/* we don't look at files with newlines in their name */
gcc_pure
static
bool
skip_path
(
const
char
*
name_utf8
)
noexcept
...
...
src/fs/Traits.hxx
View file @
b7ce4523
...
...
@@ -109,6 +109,12 @@ struct PathTraitsFS {
}
gcc_pure
gcc_nonnull_all
static
bool
IsSpecialFilename
(
const_pointer_type
name
)
noexcept
{
return
(
name
[
0
]
==
'.'
&&
name
[
1
]
==
0
)
||
(
name
[
0
]
==
'.'
&&
name
[
1
]
==
'.'
&&
name
[
2
]
==
0
);
}
gcc_pure
gcc_nonnull_all
static
size_t
GetLength
(
const_pointer_type
p
)
noexcept
{
return
StringLength
(
p
);
}
...
...
@@ -217,6 +223,12 @@ struct PathTraitsUTF8 {
}
gcc_pure
gcc_nonnull_all
static
bool
IsSpecialFilename
(
const_pointer_type
name
)
noexcept
{
return
(
name
[
0
]
==
'.'
&&
name
[
1
]
==
0
)
||
(
name
[
0
]
==
'.'
&&
name
[
1
]
==
'.'
&&
name
[
2
]
==
0
);
}
gcc_pure
gcc_nonnull_all
static
size_t
GetLength
(
const_pointer_type
p
)
noexcept
{
return
StringLength
(
p
);
}
...
...
src/storage/plugins/LocalStorage.cxx
View file @
b7ce4523
...
...
@@ -144,21 +144,12 @@ LocalStorage::OpenDirectory(const char *uri_utf8)
return
std
::
make_unique
<
LocalDirectoryReader
>
(
MapFSOrThrow
(
uri_utf8
));
}
gcc_pure
static
bool
SkipNameFS
(
PathTraitsFS
::
const_pointer_type
name_fs
)
noexcept
{
return
name_fs
[
0
]
==
'.'
&&
(
name_fs
[
1
]
==
0
||
(
name_fs
[
1
]
==
'.'
&&
name_fs
[
2
]
==
0
));
}
const
char
*
LocalDirectoryReader
::
Read
()
noexcept
{
while
(
reader
.
ReadEntry
())
{
const
Path
name_fs
=
reader
.
GetEntry
();
if
(
SkipNameFS
(
name_fs
.
c_str
()))
if
(
PathTraitsFS
::
IsSpecialFilename
(
name_fs
.
c_str
()))
continue
;
try
{
...
...
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