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
fe7c6fee
Commit
fe7c6fee
authored
Feb 08, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ArchivePlugin: pass Path to open()
parent
9906daec
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
25 additions
and
17 deletions
+25
-17
ArchivePlugin.cxx
src/archive/ArchivePlugin.cxx
+3
-2
ArchivePlugin.hxx
src/archive/ArchivePlugin.hxx
+3
-2
Bzip2ArchivePlugin.cxx
src/archive/plugins/Bzip2ArchivePlugin.cxx
+6
-4
Iso9660ArchivePlugin.cxx
src/archive/plugins/Iso9660ArchivePlugin.cxx
+5
-3
ZzipArchivePlugin.cxx
src/archive/plugins/ZzipArchivePlugin.cxx
+4
-3
Archive.cxx
src/db/update/Archive.cxx
+1
-1
ArchiveInputPlugin.cxx
src/input/plugins/ArchiveInputPlugin.cxx
+2
-1
visit_archive.cxx
test/visit_archive.cxx
+1
-1
No files found.
src/archive/ArchivePlugin.cxx
View file @
fe7c6fee
...
...
@@ -20,17 +20,18 @@
#include "config.h"
#include "ArchivePlugin.hxx"
#include "ArchiveFile.hxx"
#include "fs/Path.hxx"
#include "util/Error.hxx"
#include <assert.h>
ArchiveFile
*
archive_file_open
(
const
ArchivePlugin
*
plugin
,
const
char
*
path
,
archive_file_open
(
const
ArchivePlugin
*
plugin
,
Path
path
,
Error
&
error
)
{
assert
(
plugin
!=
nullptr
);
assert
(
plugin
->
open
!=
nullptr
);
assert
(
path
!=
nullptr
);
assert
(
!
path
.
IsNull
()
);
ArchiveFile
*
file
=
plugin
->
open
(
path
,
error
);
assert
((
file
==
nullptr
)
==
error
.
IsDefined
());
...
...
src/archive/ArchivePlugin.hxx
View file @
fe7c6fee
...
...
@@ -21,6 +21,7 @@
#define MPD_ARCHIVE_PLUGIN_HXX
class
ArchiveFile
;
class
Path
;
class
Error
;
struct
ArchivePlugin
{
...
...
@@ -44,7 +45,7 @@ struct ArchivePlugin {
* returns pointer to handle used is all operations with this archive
* or nullptr when opening fails
*/
ArchiveFile
*
(
*
open
)(
const
char
*
path_fs
,
Error
&
error
);
ArchiveFile
*
(
*
open
)(
Path
path_fs
,
Error
&
error
);
/**
* suffixes handled by this plugin.
...
...
@@ -54,7 +55,7 @@ struct ArchivePlugin {
};
ArchiveFile
*
archive_file_open
(
const
ArchivePlugin
*
plugin
,
const
char
*
path
,
archive_file_open
(
const
ArchivePlugin
*
plugin
,
Path
path
,
Error
&
error
);
#endif
src/archive/plugins/Bzip2ArchivePlugin.cxx
View file @
fe7c6fee
...
...
@@ -32,6 +32,7 @@
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include "fs/Traits.hxx"
#include "fs/Path.hxx"
#include <bzlib.h>
...
...
@@ -49,9 +50,9 @@ public:
std
::
string
name
;
InputStream
*
const
istream
;
Bzip2ArchiveFile
(
const
char
*
path
,
InputStream
*
_is
)
Bzip2ArchiveFile
(
Path
path
,
InputStream
*
_is
)
:
ArchiveFile
(
bz2_archive_plugin
),
name
(
PathTraits
UTF8
::
GetBase
(
path
)),
name
(
PathTraits
FS
::
GetBase
(
path
.
c_str
()
)),
istream
(
_is
)
{
// remove .bz2 suffix
const
size_t
len
=
name
.
length
();
...
...
@@ -142,11 +143,12 @@ Bzip2InputStream::Close()
/* archive open && listing routine */
static
ArchiveFile
*
bz2_open
(
const
char
*
pathname
,
Error
&
error
)
bz2_open
(
Path
pathname
,
Error
&
error
)
{
static
Mutex
mutex
;
static
Cond
cond
;
InputStream
*
is
=
InputStream
::
OpenReady
(
pathname
,
mutex
,
cond
,
error
);
InputStream
*
is
=
InputStream
::
OpenReady
(
pathname
.
c_str
(),
mutex
,
cond
,
error
);
if
(
is
==
nullptr
)
return
nullptr
;
...
...
src/archive/plugins/Iso9660ArchivePlugin.cxx
View file @
fe7c6fee
...
...
@@ -28,6 +28,7 @@
#include "../ArchiveVisitor.hxx"
#include "input/InputStream.hxx"
#include "input/InputPlugin.hxx"
#include "fs/Path.hxx"
#include "util/RefCount.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
...
...
@@ -117,13 +118,14 @@ Iso9660ArchiveFile::Visit(const char *psz_path, ArchiveVisitor &visitor)
}
static
ArchiveFile
*
iso9660_archive_open
(
const
char
*
pathname
,
Error
&
error
)
iso9660_archive_open
(
Path
pathname
,
Error
&
error
)
{
/* open archive */
auto
iso
=
iso9660_open
(
pathname
);
auto
iso
=
iso9660_open
(
pathname
.
c_str
()
);
if
(
iso
==
nullptr
)
{
error
.
Format
(
iso9660_domain
,
"Failed to open ISO9660 file %s"
,
pathname
);
"Failed to open ISO9660 file %s"
,
pathname
.
c_str
());
return
nullptr
;
}
...
...
src/archive/plugins/ZzipArchivePlugin.cxx
View file @
fe7c6fee
...
...
@@ -28,6 +28,7 @@
#include "../ArchiveVisitor.hxx"
#include "input/InputStream.hxx"
#include "input/InputPlugin.hxx"
#include "fs/Path.hxx"
#include "util/RefCount.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
...
...
@@ -70,12 +71,12 @@ static constexpr Domain zzip_domain("zzip");
/* archive open && listing routine */
static
ArchiveFile
*
zzip_archive_open
(
const
char
*
pathname
,
Error
&
error
)
zzip_archive_open
(
Path
pathname
,
Error
&
error
)
{
ZZIP_DIR
*
dir
=
zzip_dir_open
(
pathname
,
nullptr
);
ZZIP_DIR
*
dir
=
zzip_dir_open
(
pathname
.
c_str
()
,
nullptr
);
if
(
dir
==
nullptr
)
{
error
.
Format
(
zzip_domain
,
"Failed to open ZIP file %s"
,
pathname
);
pathname
.
c_str
()
);
return
nullptr
;
}
...
...
src/db/update/Archive.cxx
View file @
fe7c6fee
...
...
@@ -125,7 +125,7 @@ UpdateWalk::UpdateArchiveFile(Directory &parent, const char *name,
/* open archive */
Error
error
;
ArchiveFile
*
file
=
archive_file_open
(
&
plugin
,
path_fs
.
c_str
()
,
error
);
ArchiveFile
*
file
=
archive_file_open
(
&
plugin
,
path_fs
,
error
);
if
(
file
==
nullptr
)
{
LogError
(
error
);
if
(
directory
!=
nullptr
)
...
...
src/input/plugins/ArchiveInputPlugin.cxx
View file @
fe7c6fee
...
...
@@ -26,6 +26,7 @@
#include "archive/ArchiveFile.hxx"
#include "../InputPlugin.hxx"
#include "fs/Traits.hxx"
#include "fs/Path.hxx"
#include "util/Alloc.hxx"
#include "Log.hxx"
...
...
@@ -69,7 +70,7 @@ input_archive_open(const char *pathname,
return
nullptr
;
}
auto
file
=
archive_file_open
(
arplug
,
archive
,
error
);
auto
file
=
archive_file_open
(
arplug
,
Path
::
FromFS
(
archive
)
,
error
);
if
(
file
==
nullptr
)
{
free
(
pname
);
return
nullptr
;
...
...
test/visit_archive.cxx
View file @
fe7c6fee
...
...
@@ -85,7 +85,7 @@ main(int argc, char **argv)
int
result
=
EXIT_SUCCESS
;
ArchiveFile
*
file
=
archive_file_open
(
plugin
,
path
.
c_str
()
,
error
);
ArchiveFile
*
file
=
archive_file_open
(
plugin
,
path
,
error
);
if
(
file
!=
nullptr
)
{
MyArchiveVisitor
visitor
;
file
->
Visit
(
visitor
);
...
...
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