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
fa13648f
Commit
fa13648f
authored
May 31, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
archive/ArchiveLookup: throw on error
parent
2f83ed90
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
10 deletions
+19
-10
ArchiveLookup.cxx
src/archive/ArchiveLookup.cxx
+4
-5
ArchiveLookup.hxx
src/archive/ArchiveLookup.hxx
+2
-0
ArchiveInputPlugin.cxx
src/input/plugins/ArchiveInputPlugin.cxx
+9
-3
test_archive.cxx
test/test_archive.cxx
+4
-2
No files found.
src/archive/ArchiveLookup.cxx
View file @
fa13648f
...
...
@@ -20,6 +20,7 @@
#include "ArchiveLookup.hxx"
#include "ArchiveDomain.hxx"
#include "Log.hxx"
#include "system/Error.hxx"
#include <string.h>
#include <sys/stat.h>
...
...
@@ -60,11 +61,9 @@ archive_lookup(char *pathname, const char **archive,
//try to stat if its real directory
struct
stat
st_info
;
if
(
stat
(
pathname
,
&
st_info
)
==
-
1
)
{
if
(
errno
!=
ENOTDIR
)
{
FormatErrno
(
archive_domain
,
"Failed to stat %s"
,
pathname
);
return
false
;
}
int
e
=
errno
;
if
(
e
!=
ENOTDIR
)
throw
FormatErrno
(
e
,
"Failed to stat %s"
,
pathname
);
}
else
{
//is something found ins original path (is not an archive)
if
(
slash
==
nullptr
)
...
...
src/archive/ArchiveLookup.hxx
View file @
fa13648f
...
...
@@ -36,6 +36,8 @@
* is split into archive: /music/path/Talco.zip
* inarchive pathname: Talco - Combat Circus/12 - A la pachenka.mp3
* and suffix: zip
*
* Throws on error.
*/
bool
archive_lookup
(
char
*
pathname
,
const
char
**
archive
,
...
...
src/input/plugins/ArchiveInputPlugin.cxx
View file @
fa13648f
...
...
@@ -45,9 +45,15 @@ OpenArchiveInputStream(Path path, Mutex &mutex)
// archive_lookup will modify pname when true is returned
const
char
*
archive
,
*
filename
,
*
suffix
;
if
(
!
archive_lookup
(
pname
,
&
archive
,
&
filename
,
&
suffix
))
{
FormatDebug
(
archive_domain
,
"not an archive, lookup %s failed"
,
pname
);
try
{
if
(
!
archive_lookup
(
pname
,
&
archive
,
&
filename
,
&
suffix
))
{
FormatDebug
(
archive_domain
,
"not an archive, lookup %s failed"
,
pname
);
return
nullptr
;
}
}
catch
(...)
{
LogFormat
(
LogLevel
::
DEBUG
,
std
::
current_exception
(),
"not an archive, lookup %s failed"
,
pname
);
return
nullptr
;
}
...
...
test/test_archive.cxx
View file @
fa13648f
...
...
@@ -11,7 +11,8 @@ TEST(ArchiveTest, Lookup)
const
char
*
archive
,
*
inpath
,
*
suffix
;
char
*
path
=
strdup
(
""
);
EXPECT_FALSE
(
archive_lookup
(
path
,
&
archive
,
&
inpath
,
&
suffix
));
EXPECT_THROW
(
archive_lookup
(
path
,
&
archive
,
&
inpath
,
&
suffix
),
std
::
system_error
);
free
(
path
);
path
=
strdup
(
"."
);
...
...
@@ -23,7 +24,8 @@ TEST(ArchiveTest, Lookup)
free
(
path
);
path
=
strdup
(
"src/foo/bar"
);
EXPECT_FALSE
(
archive_lookup
(
path
,
&
archive
,
&
inpath
,
&
suffix
));
EXPECT_THROW
(
archive_lookup
(
path
,
&
archive
,
&
inpath
,
&
suffix
),
std
::
system_error
);
free
(
path
);
fclose
(
fopen
(
"dummy"
,
"w"
));
...
...
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