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
83f9d2a9
Commit
83f9d2a9
authored
Sep 16, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/update/InotifyUpdate: use class DirectoryReader
parent
bf97ebf8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
19 deletions
+14
-19
InotifyUpdate.cxx
src/db/update/InotifyUpdate.cxx
+14
-19
No files found.
src/db/update/InotifyUpdate.cxx
View file @
83f9d2a9
...
...
@@ -23,8 +23,10 @@
#include "InotifyDomain.hxx"
#include "storage/StorageInterface.hxx"
#include "fs/AllocatedPath.hxx"
#include "fs/DirectoryReader.hxx"
#include "fs/FileInfo.hxx"
#include "fs/Traits.hxx"
#include "util/Compiler.h"
#include "Log.hxx"
#include <cassert>
...
...
@@ -145,19 +147,18 @@ WatchDirectory::GetUriFS() const noexcept
}
/* we don't look at "." / ".." nor files with newlines in their name */
static
bool
skip_path
(
const
char
*
path
)
gcc_pure
static
bool
SkipFilename
(
Path
name
)
noexcept
{
return
PathTraitsFS
::
IsSpecialFilename
(
path
)
||
std
::
strchr
(
path
,
'\n'
)
!=
nullptr
;
return
PathTraitsFS
::
IsSpecialFilename
(
name
.
c_str
()
)
||
name
.
HasNewline
()
;
}
static
void
recursive_watch_subdirectories
(
WatchDirectory
&
parent
,
const
AllocatedPath
&
path_fs
,
unsigned
depth
)
{
DIR
*
dir
;
struct
dirent
*
ent
;
try
{
assert
(
depth
<=
inotify_max_depth
);
assert
(
!
path_fs
.
IsNull
());
...
...
@@ -166,20 +167,14 @@ recursive_watch_subdirectories(WatchDirectory &parent,
if
(
depth
>
inotify_max_depth
)
return
;
dir
=
opendir
(
path_fs
.
c_str
());
if
(
dir
==
nullptr
)
{
FormatErrno
(
inotify_domain
,
"Failed to open directory %s"
,
path_fs
.
c_str
());
return
;
}
while
((
ent
=
readdir
(
dir
)))
{
DirectoryReader
dir
(
path_fs
);
while
(
dir
.
ReadEntry
())
{
int
ret
;
if
(
skip_path
(
ent
->
d_name
))
const
Path
name_fs
=
dir
.
GetEntry
();
if
(
SkipFilename
(
name_fs
))
continue
;
const
auto
name_fs
=
Path
::
FromFS
(
ent
->
d_name
);
const
auto
child_path_fs
=
path_fs
/
name_fs
;
FileInfo
fi
;
...
...
@@ -217,8 +212,8 @@ recursive_watch_subdirectories(WatchDirectory &parent,
recursive_watch_subdirectories
(
*
child
,
child_path_fs
,
depth
);
}
closedir
(
dir
);
}
catch
(...)
{
LogError
(
std
::
current_exception
()
);
}
gcc_pure
...
...
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