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
fe1e467a
Commit
fe1e467a
authored
Feb 25, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/ExcludeList: use the TextFile class instead of stdio.h
parent
73cb538d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
17 deletions
+24
-17
ExcludeList.cxx
src/db/update/ExcludeList.cxx
+24
-17
No files found.
src/db/update/ExcludeList.cxx
View file @
fe1e467a
...
...
@@ -25,36 +25,45 @@
#include "config.h"
#include "ExcludeList.hxx"
#include "fs/Path.hxx"
#include "fs/
FileSystem
.hxx"
#include "fs/
io/TextFile
.hxx"
#include "util/StringUtil.hxx"
#include "util/
Domain
.hxx"
#include "util/
Error
.hxx"
#include "Log.hxx"
#include <assert.h>
#include <string.h>
#include <errno.h>
static
constexpr
Domain
exclude_list_domain
(
"exclude_list"
);
#ifdef HAVE_GLIB
gcc_pure
static
bool
IsFileNotFound
(
const
Error
&
error
)
{
#ifdef WIN32
return
error
.
IsDomain
(
win32_domain
)
&&
error
.
GetCode
()
==
ERROR_FILE_NOT_FOUND
;
#else
return
error
.
IsDomain
(
errno_domain
)
&&
error
.
GetCode
()
==
ENOENT
;
#endif
}
#endif
bool
ExcludeList
::
LoadFile
(
Path
path_fs
)
{
#ifdef HAVE_GLIB
FILE
*
file
=
FOpen
(
path_fs
,
FOpenMode
::
ReadText
);
if
(
file
==
nullptr
)
{
const
int
e
=
errno
;
if
(
e
!=
ENOENT
)
{
const
auto
path_utf8
=
path_fs
.
ToUTF8
();
FormatErrno
(
exclude_list_domain
,
"Failed to open %s"
,
path_utf8
.
c_str
());
}
Error
error
;
TextFile
file
(
path_fs
,
error
);
if
(
file
.
HasFailed
())
{
if
(
!
IsFileNotFound
(
error
))
LogError
(
error
);
return
false
;
}
char
line
[
1024
]
;
while
(
fgets
(
line
,
sizeof
(
line
),
file
)
!=
nullptr
)
{
char
*
line
;
while
(
(
line
=
file
.
ReadLine
()
)
!=
nullptr
)
{
char
*
p
=
strchr
(
line
,
'#'
);
if
(
p
!=
nullptr
)
*
p
=
0
;
...
...
@@ -63,8 +72,6 @@ ExcludeList::LoadFile(Path path_fs)
if
(
*
p
!=
0
)
patterns
.
emplace_front
(
p
);
}
fclose
(
file
);
#else
// TODO: implement
(
void
)
path_fs
;
...
...
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