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
f5c0b0d3
Commit
f5c0b0d3
authored
Jan 29, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ArchiveFile: convert to a class
parent
ba51045d
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
66 additions
and
85 deletions
+66
-85
Makefile.am
Makefile.am
+1
-1
ArchiveFile.hxx
src/ArchiveFile.hxx
+8
-11
ArchivePlugin.cxx
src/ArchivePlugin.cxx
+15
-21
ArchivePlugin.hxx
src/ArchivePlugin.hxx
+9
-9
UpdateArchive.cxx
src/UpdateArchive.cxx
+1
-2
Bzip2ArchivePlugin.cxx
src/archive/Bzip2ArchivePlugin.cxx
+10
-13
Iso9660ArchivePlugin.cxx
src/archive/Iso9660ArchivePlugin.cxx
+9
-13
ZzipArchivePlugin.cxx
src/archive/ZzipArchivePlugin.cxx
+9
-12
ArchiveInputPlugin.cxx
src/input/ArchiveInputPlugin.cxx
+1
-2
visit_archive.cxx
test/visit_archive.cxx
+3
-1
No files found.
Makefile.am
View file @
f5c0b0d3
...
@@ -399,7 +399,7 @@ libarchive_a_SOURCES = \
...
@@ -399,7 +399,7 @@ libarchive_a_SOURCES = \
src/ArchiveList.cxx src/ArchiveList.hxx
\
src/ArchiveList.cxx src/ArchiveList.hxx
\
src/ArchivePlugin.cxx src/ArchivePlugin.hxx
\
src/ArchivePlugin.cxx src/ArchivePlugin.hxx
\
src/ArchiveVisitor.hxx
\
src/ArchiveVisitor.hxx
\
src/Archive
Internal
.hxx
\
src/Archive
File
.hxx
\
src/input/ArchiveInputPlugin.cxx src/input/ArchiveInputPlugin.hxx
src/input/ArchiveInputPlugin.cxx src/input/ArchiveInputPlugin.hxx
libarchive_a_CPPFLAGS
=
$(AM_CPPFLAGS)
\
libarchive_a_CPPFLAGS
=
$(AM_CPPFLAGS)
\
$(BZ2_CFLAGS)
\
$(BZ2_CFLAGS)
\
...
...
src/Archive
Internal
.hxx
→
src/Archive
File
.hxx
View file @
f5c0b0d3
...
@@ -17,18 +17,15 @@
...
@@ -17,18 +17,15 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
*/
#ifndef MPD_ARCHIVE_
INTERNAL
_HXX
#ifndef MPD_ARCHIVE_
FILE
_HXX
#define MPD_ARCHIVE_
INTERNAL
_HXX
#define MPD_ARCHIVE_
FILE
_HXX
struct
archive_f
ile
{
class
ArchiveF
ile
{
const
struct
archive_plugin
*
plugin
;
public
:
}
;
const
struct
archive_plugin
&
plugin
;
static
inline
void
ArchiveFile
(
const
struct
archive_plugin
&
_plugin
)
archive_file_init
(
struct
archive_file
*
archive_file
,
:
plugin
(
_plugin
)
{}
const
struct
archive_plugin
*
plugin
)
};
{
archive_file
->
plugin
=
plugin
;
}
#endif
#endif
src/ArchivePlugin.cxx
View file @
f5c0b0d3
...
@@ -18,28 +18,25 @@
...
@@ -18,28 +18,25 @@
*/
*/
#include "ArchivePlugin.hxx"
#include "ArchivePlugin.hxx"
#include "Archive
Internal
.hxx"
#include "Archive
File
.hxx"
#include <assert.h>
#include <assert.h>
struct
archive_f
ile
*
ArchiveF
ile
*
archive_file_open
(
const
struct
archive_plugin
*
plugin
,
const
char
*
path
,
archive_file_open
(
const
struct
archive_plugin
*
plugin
,
const
char
*
path
,
GError
**
error_r
)
GError
**
error_r
)
{
{
struct
archive_file
*
file
;
assert
(
plugin
!=
NULL
);
assert
(
plugin
!=
NULL
);
assert
(
plugin
->
open
!=
NULL
);
assert
(
plugin
->
open
!=
NULL
);
assert
(
path
!=
NULL
);
assert
(
path
!=
NULL
);
assert
(
error_r
==
NULL
||
*
error_r
==
NULL
);
assert
(
error_r
==
NULL
||
*
error_r
==
NULL
);
file
=
plugin
->
open
(
path
,
error_r
);
ArchiveFile
*
file
=
plugin
->
open
(
path
,
error_r
);
if
(
file
!=
NULL
)
{
if
(
file
!=
NULL
)
{
assert
(
file
->
plugin
!=
NULL
);
assert
(
file
->
plugin
.
close
!=
NULL
);
assert
(
file
->
plugin
->
close
!=
NULL
);
assert
(
file
->
plugin
.
visit
!=
nullptr
);
assert
(
file
->
plugin
->
visit
!=
nullptr
);
assert
(
file
->
plugin
.
open_stream
!=
NULL
);
assert
(
file
->
plugin
->
open_stream
!=
NULL
);
assert
(
error_r
==
NULL
||
*
error_r
==
NULL
);
assert
(
error_r
==
NULL
||
*
error_r
==
NULL
);
}
else
{
}
else
{
assert
(
error_r
==
NULL
||
*
error_r
!=
NULL
);
assert
(
error_r
==
NULL
||
*
error_r
!=
NULL
);
...
@@ -49,34 +46,31 @@ archive_file_open(const struct archive_plugin *plugin, const char *path,
...
@@ -49,34 +46,31 @@ archive_file_open(const struct archive_plugin *plugin, const char *path,
}
}
void
void
archive_file_close
(
struct
archive_f
ile
*
file
)
archive_file_close
(
ArchiveF
ile
*
file
)
{
{
assert
(
file
!=
NULL
);
assert
(
file
!=
NULL
);
assert
(
file
->
plugin
!=
NULL
);
assert
(
file
->
plugin
.
close
!=
NULL
);
assert
(
file
->
plugin
->
close
!=
NULL
);
file
->
plugin
->
close
(
file
);
file
->
plugin
.
close
(
file
);
}
}
void
void
archive_file_visit
(
archive_f
ile
*
file
,
ArchiveVisitor
&
visitor
)
archive_file_visit
(
ArchiveF
ile
*
file
,
ArchiveVisitor
&
visitor
)
{
{
assert
(
file
!=
NULL
);
assert
(
file
!=
NULL
);
assert
(
file
->
plugin
!=
NULL
);
assert
(
file
->
plugin
.
visit
!=
nullptr
);
assert
(
file
->
plugin
->
visit
!=
nullptr
);
file
->
plugin
->
visit
(
file
,
visitor
);
file
->
plugin
.
visit
(
file
,
visitor
);
}
}
struct
input_stream
*
struct
input_stream
*
archive_file_open_stream
(
struct
archive_f
ile
*
file
,
const
char
*
path
,
archive_file_open_stream
(
ArchiveF
ile
*
file
,
const
char
*
path
,
Mutex
&
mutex
,
Cond
&
cond
,
Mutex
&
mutex
,
Cond
&
cond
,
GError
**
error_r
)
GError
**
error_r
)
{
{
assert
(
file
!=
NULL
);
assert
(
file
!=
NULL
);
assert
(
file
->
plugin
!=
NULL
);
assert
(
file
->
plugin
.
open_stream
!=
NULL
);
assert
(
file
->
plugin
->
open_stream
!=
NULL
);
return
file
->
plugin
->
open_stream
(
file
,
path
,
mutex
,
cond
,
return
file
->
plugin
.
open_stream
(
file
,
path
,
mutex
,
cond
,
error_r
);
error_r
);
}
}
src/ArchivePlugin.hxx
View file @
f5c0b0d3
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
#include "gerror.h"
#include "gerror.h"
struct
input_stream
;
struct
input_stream
;
struct
archive_f
ile
;
class
ArchiveF
ile
;
class
ArchiveVisitor
;
class
ArchiveVisitor
;
struct
archive_plugin
{
struct
archive_plugin
{
...
@@ -49,12 +49,12 @@ struct archive_plugin {
...
@@ -49,12 +49,12 @@ struct archive_plugin {
* returns pointer to handle used is all operations with this archive
* returns pointer to handle used is all operations with this archive
* or NULL when opening fails
* or NULL when opening fails
*/
*/
struct
archive_f
ile
*
(
*
open
)(
const
char
*
path_fs
,
GError
**
error_r
);
ArchiveF
ile
*
(
*
open
)(
const
char
*
path_fs
,
GError
**
error_r
);
/**
/**
* Visit all entries inside this archive.
* Visit all entries inside this archive.
*/
*/
void
(
*
visit
)(
archive_f
ile
*
af
,
ArchiveVisitor
&
visitor
);
void
(
*
visit
)(
ArchiveF
ile
*
af
,
ArchiveVisitor
&
visitor
);
/**
/**
* Opens an input_stream of a file within the archive.
* Opens an input_stream of a file within the archive.
...
@@ -63,7 +63,7 @@ struct archive_plugin {
...
@@ -63,7 +63,7 @@ struct archive_plugin {
* @param error_r location to store the error occurring, or
* @param error_r location to store the error occurring, or
* NULL to ignore errors
* NULL to ignore errors
*/
*/
struct
input_stream
*
(
*
open_stream
)(
struct
archive_f
ile
*
af
,
struct
input_stream
*
(
*
open_stream
)(
ArchiveF
ile
*
af
,
const
char
*
path
,
const
char
*
path
,
Mutex
&
mutex
,
Cond
&
cond
,
Mutex
&
mutex
,
Cond
&
cond
,
GError
**
error_r
);
GError
**
error_r
);
...
@@ -71,7 +71,7 @@ struct archive_plugin {
...
@@ -71,7 +71,7 @@ struct archive_plugin {
/**
/**
* closes archive file.
* closes archive file.
*/
*/
void
(
*
close
)(
struct
archive_f
ile
*
);
void
(
*
close
)(
ArchiveF
ile
*
);
/**
/**
* suffixes handled by this plugin.
* suffixes handled by this plugin.
...
@@ -80,18 +80,18 @@ struct archive_plugin {
...
@@ -80,18 +80,18 @@ struct archive_plugin {
const
char
*
const
*
suffixes
;
const
char
*
const
*
suffixes
;
};
};
struct
archive_f
ile
*
ArchiveF
ile
*
archive_file_open
(
const
struct
archive_plugin
*
plugin
,
const
char
*
path
,
archive_file_open
(
const
struct
archive_plugin
*
plugin
,
const
char
*
path
,
GError
**
error_r
);
GError
**
error_r
);
void
void
archive_file_close
(
struct
archive_f
ile
*
file
);
archive_file_close
(
ArchiveF
ile
*
file
);
void
void
archive_file_visit
(
archive_f
ile
*
file
,
ArchiveVisitor
&
visitor
);
archive_file_visit
(
ArchiveF
ile
*
file
,
ArchiveVisitor
&
visitor
);
struct
input_stream
*
struct
input_stream
*
archive_file_open_stream
(
struct
archive_f
ile
*
file
,
const
char
*
path
,
archive_file_open_stream
(
ArchiveF
ile
*
file
,
const
char
*
path
,
Mutex
&
mutex
,
Cond
&
cond
,
Mutex
&
mutex
,
Cond
&
cond
,
GError
**
error_r
);
GError
**
error_r
);
...
...
src/UpdateArchive.cxx
View file @
f5c0b0d3
...
@@ -101,8 +101,7 @@ update_archive_file2(Directory *parent, const char *name,
...
@@ -101,8 +101,7 @@ update_archive_file2(Directory *parent, const char *name,
/* open archive */
/* open archive */
GError
*
error
=
NULL
;
GError
*
error
=
NULL
;
struct
archive_file
*
file
=
archive_file_open
(
plugin
,
path_fs
.
c_str
(),
ArchiveFile
*
file
=
archive_file_open
(
plugin
,
path_fs
.
c_str
(),
&
error
);
&
error
);
if
(
file
==
NULL
)
{
if
(
file
==
NULL
)
{
g_warning
(
"%s"
,
error
->
message
);
g_warning
(
"%s"
,
error
->
message
);
g_error_free
(
error
);
g_error_free
(
error
);
...
...
src/archive/Bzip2ArchivePlugin.cxx
View file @
f5c0b0d3
...
@@ -23,8 +23,8 @@
...
@@ -23,8 +23,8 @@
#include "config.h"
#include "config.h"
#include "Bzip2ArchivePlugin.hxx"
#include "Bzip2ArchivePlugin.hxx"
#include "ArchiveInternal.hxx"
#include "ArchivePlugin.hxx"
#include "ArchivePlugin.hxx"
#include "ArchiveFile.hxx"
#include "ArchiveVisitor.hxx"
#include "ArchiveVisitor.hxx"
#include "InputInternal.hxx"
#include "InputInternal.hxx"
#include "InputStream.hxx"
#include "InputStream.hxx"
...
@@ -42,17 +42,14 @@
...
@@ -42,17 +42,14 @@
#define BZ2_bzDecompress bzDecompress
#define BZ2_bzDecompress bzDecompress
#endif
#endif
struct
Bzip2ArchiveFile
{
class
Bzip2ArchiveFile
:
public
ArchiveFile
{
struct
archive_file
base
;
public
:
RefCount
ref
;
RefCount
ref
;
char
*
name
;
char
*
name
;
struct
input_stream
*
istream
;
struct
input_stream
*
istream
;
Bzip2ArchiveFile
()
{
Bzip2ArchiveFile
()
:
ArchiveFile
(
bz2_archive_plugin
)
{}
archive_file_init
(
&
base
,
&
bz2_archive_plugin
);
}
void
Unref
()
{
void
Unref
()
{
if
(
!
ref
.
Decrement
())
if
(
!
ref
.
Decrement
())
...
@@ -123,7 +120,7 @@ Bzip2InputStream::Close()
...
@@ -123,7 +120,7 @@ Bzip2InputStream::Close()
/* archive open && listing routine */
/* archive open && listing routine */
static
struct
archive_f
ile
*
static
ArchiveF
ile
*
bz2_open
(
const
char
*
pathname
,
GError
**
error_r
)
bz2_open
(
const
char
*
pathname
,
GError
**
error_r
)
{
{
Bzip2ArchiveFile
*
context
=
new
Bzip2ArchiveFile
();
Bzip2ArchiveFile
*
context
=
new
Bzip2ArchiveFile
();
...
@@ -147,11 +144,11 @@ bz2_open(const char *pathname, GError **error_r)
...
@@ -147,11 +144,11 @@ bz2_open(const char *pathname, GError **error_r)
context
->
name
[
len
-
4
]
=
0
;
//remove .bz2 suffix
context
->
name
[
len
-
4
]
=
0
;
//remove .bz2 suffix
}
}
return
&
context
->
base
;
return
context
;
}
}
static
void
static
void
bz2_visit
(
archive_f
ile
*
file
,
ArchiveVisitor
&
visitor
)
bz2_visit
(
ArchiveF
ile
*
file
,
ArchiveVisitor
&
visitor
)
{
{
Bzip2ArchiveFile
*
context
=
(
Bzip2ArchiveFile
*
)
file
;
Bzip2ArchiveFile
*
context
=
(
Bzip2ArchiveFile
*
)
file
;
...
@@ -159,7 +156,7 @@ bz2_visit(archive_file *file, ArchiveVisitor &visitor)
...
@@ -159,7 +156,7 @@ bz2_visit(archive_file *file, ArchiveVisitor &visitor)
}
}
static
void
static
void
bz2_close
(
struct
archive_f
ile
*
file
)
bz2_close
(
ArchiveF
ile
*
file
)
{
{
Bzip2ArchiveFile
*
context
=
(
Bzip2ArchiveFile
*
)
file
;
Bzip2ArchiveFile
*
context
=
(
Bzip2ArchiveFile
*
)
file
;
...
@@ -178,11 +175,11 @@ Bzip2InputStream::Bzip2InputStream(Bzip2ArchiveFile &_context, const char *uri,
...
@@ -178,11 +175,11 @@ Bzip2InputStream::Bzip2InputStream(Bzip2ArchiveFile &_context, const char *uri,
Bzip2InputStream
::~
Bzip2InputStream
()
Bzip2InputStream
::~
Bzip2InputStream
()
{
{
bz2_close
(
&
archive
->
base
);
archive
->
Unref
(
);
}
}
static
struct
input_stream
*
static
struct
input_stream
*
bz2_open_stream
(
struct
archive_f
ile
*
file
,
const
char
*
path
,
bz2_open_stream
(
ArchiveF
ile
*
file
,
const
char
*
path
,
Mutex
&
mutex
,
Cond
&
cond
,
Mutex
&
mutex
,
Cond
&
cond
,
GError
**
error_r
)
GError
**
error_r
)
{
{
...
...
src/archive/Iso9660ArchivePlugin.cxx
View file @
f5c0b0d3
...
@@ -23,8 +23,8 @@
...
@@ -23,8 +23,8 @@
#include "config.h"
#include "config.h"
#include "Iso9660ArchivePlugin.hxx"
#include "Iso9660ArchivePlugin.hxx"
#include "ArchiveInternal.hxx"
#include "ArchivePlugin.hxx"
#include "ArchivePlugin.hxx"
#include "ArchiveFile.hxx"
#include "ArchiveVisitor.hxx"
#include "ArchiveVisitor.hxx"
#include "InputInternal.hxx"
#include "InputInternal.hxx"
#include "InputStream.hxx"
#include "InputStream.hxx"
...
@@ -41,17 +41,14 @@
...
@@ -41,17 +41,14 @@
#define CEILING(x, y) ((x+(y-1))/y)
#define CEILING(x, y) ((x+(y-1))/y)
struct
Iso9660ArchiveFile
{
class
Iso9660ArchiveFile
:
public
ArchiveFile
{
struct
archive_file
base
;
public
:
RefCount
ref
;
RefCount
ref
;
iso9660_t
*
iso
;
iso9660_t
*
iso
;
Iso9660ArchiveFile
(
iso9660_t
*
_iso
)
Iso9660ArchiveFile
(
iso9660_t
*
_iso
)
:
iso
(
_iso
)
{
:
ArchiveFile
(
iso9660_archive_plugin
),
iso
(
_iso
)
{}
archive_file_init
(
&
base
,
&
iso9660_archive_plugin
);
}
~
Iso9660ArchiveFile
()
{
~
Iso9660ArchiveFile
()
{
iso9660_close
(
iso
);
iso9660_close
(
iso
);
...
@@ -107,7 +104,7 @@ Iso9660ArchiveFile::Visit(const char *psz_path, ArchiveVisitor &visitor)
...
@@ -107,7 +104,7 @@ Iso9660ArchiveFile::Visit(const char *psz_path, ArchiveVisitor &visitor)
_cdio_list_free
(
entlist
,
true
);
_cdio_list_free
(
entlist
,
true
);
}
}
static
struct
archive_f
ile
*
static
ArchiveF
ile
*
iso9660_archive_open
(
const
char
*
pathname
,
GError
**
error_r
)
iso9660_archive_open
(
const
char
*
pathname
,
GError
**
error_r
)
{
{
/* open archive */
/* open archive */
...
@@ -118,12 +115,11 @@ iso9660_archive_open(const char *pathname, GError **error_r)
...
@@ -118,12 +115,11 @@ iso9660_archive_open(const char *pathname, GError **error_r)
return
NULL
;
return
NULL
;
}
}
Iso9660ArchiveFile
*
archive
=
new
Iso9660ArchiveFile
(
iso
);
return
new
Iso9660ArchiveFile
(
iso
);
return
&
archive
->
base
;
}
}
static
void
static
void
iso9660_archive_visit
(
archive_f
ile
*
file
,
ArchiveVisitor
&
visitor
)
iso9660_archive_visit
(
ArchiveF
ile
*
file
,
ArchiveVisitor
&
visitor
)
{
{
Iso9660ArchiveFile
*
context
=
Iso9660ArchiveFile
*
context
=
(
Iso9660ArchiveFile
*
)
file
;
(
Iso9660ArchiveFile
*
)
file
;
...
@@ -132,7 +128,7 @@ iso9660_archive_visit(archive_file *file, ArchiveVisitor &visitor)
...
@@ -132,7 +128,7 @@ iso9660_archive_visit(archive_file *file, ArchiveVisitor &visitor)
}
}
static
void
static
void
iso9660_archive_close
(
struct
archive_f
ile
*
file
)
iso9660_archive_close
(
ArchiveF
ile
*
file
)
{
{
Iso9660ArchiveFile
*
context
=
Iso9660ArchiveFile
*
context
=
(
Iso9660ArchiveFile
*
)
file
;
(
Iso9660ArchiveFile
*
)
file
;
...
@@ -170,7 +166,7 @@ struct Iso9660InputStream {
...
@@ -170,7 +166,7 @@ struct Iso9660InputStream {
};
};
static
struct
input_stream
*
static
struct
input_stream
*
iso9660_archive_open_stream
(
struct
archive_f
ile
*
file
,
const
char
*
pathname
,
iso9660_archive_open_stream
(
ArchiveF
ile
*
file
,
const
char
*
pathname
,
Mutex
&
mutex
,
Cond
&
cond
,
Mutex
&
mutex
,
Cond
&
cond
,
GError
**
error_r
)
GError
**
error_r
)
{
{
...
...
src/archive/ZzipArchivePlugin.cxx
View file @
f5c0b0d3
...
@@ -23,8 +23,8 @@
...
@@ -23,8 +23,8 @@
#include "config.h"
#include "config.h"
#include "ZzipArchivePlugin.hxx"
#include "ZzipArchivePlugin.hxx"
#include "ArchiveInternal.hxx"
#include "ArchivePlugin.hxx"
#include "ArchivePlugin.hxx"
#include "ArchiveFile.hxx"
#include "ArchiveVisitor.hxx"
#include "ArchiveVisitor.hxx"
#include "InputInternal.hxx"
#include "InputInternal.hxx"
#include "InputStream.hxx"
#include "InputStream.hxx"
...
@@ -35,16 +35,13 @@
...
@@ -35,16 +35,13 @@
#include <glib.h>
#include <glib.h>
#include <string.h>
#include <string.h>
struct
ZzipArchiveFile
{
class
ZzipArchiveFile
:
public
ArchiveFile
{
struct
archive_file
base
;
public
:
RefCount
ref
;
RefCount
ref
;
ZZIP_DIR
*
dir
;
ZZIP_DIR
*
dir
;
ZzipArchiveFile
()
{
ZzipArchiveFile
()
:
ArchiveFile
(
zzip_archive_plugin
)
{}
archive_file_init
(
&
base
,
&
zzip_archive_plugin
);
}
void
Unref
()
{
void
Unref
()
{
if
(
!
ref
.
Decrement
())
if
(
!
ref
.
Decrement
())
...
@@ -69,7 +66,7 @@ zzip_quark(void)
...
@@ -69,7 +66,7 @@ zzip_quark(void)
/* archive open && listing routine */
/* archive open && listing routine */
static
struct
archive_f
ile
*
static
ArchiveF
ile
*
zzip_archive_open
(
const
char
*
pathname
,
GError
**
error_r
)
zzip_archive_open
(
const
char
*
pathname
,
GError
**
error_r
)
{
{
ZzipArchiveFile
*
context
=
new
ZzipArchiveFile
();
ZzipArchiveFile
*
context
=
new
ZzipArchiveFile
();
...
@@ -82,7 +79,7 @@ zzip_archive_open(const char *pathname, GError **error_r)
...
@@ -82,7 +79,7 @@ zzip_archive_open(const char *pathname, GError **error_r)
return
NULL
;
return
NULL
;
}
}
return
&
context
->
base
;
return
context
;
}
}
inline
void
inline
void
...
@@ -98,7 +95,7 @@ ZzipArchiveFile::Visit(ArchiveVisitor &visitor)
...
@@ -98,7 +95,7 @@ ZzipArchiveFile::Visit(ArchiveVisitor &visitor)
}
}
static
void
static
void
zzip_archive_visit
(
archive_f
ile
*
file
,
ArchiveVisitor
&
visitor
)
zzip_archive_visit
(
ArchiveF
ile
*
file
,
ArchiveVisitor
&
visitor
)
{
{
ZzipArchiveFile
*
context
=
(
ZzipArchiveFile
*
)
file
;
ZzipArchiveFile
*
context
=
(
ZzipArchiveFile
*
)
file
;
...
@@ -106,7 +103,7 @@ zzip_archive_visit(archive_file *file, ArchiveVisitor &visitor)
...
@@ -106,7 +103,7 @@ zzip_archive_visit(archive_file *file, ArchiveVisitor &visitor)
}
}
static
void
static
void
zzip_archive_close
(
struct
archive_f
ile
*
file
)
zzip_archive_close
(
ArchiveF
ile
*
file
)
{
{
ZzipArchiveFile
*
context
=
(
ZzipArchiveFile
*
)
file
;
ZzipArchiveFile
*
context
=
(
ZzipArchiveFile
*
)
file
;
...
@@ -145,7 +142,7 @@ struct ZzipInputStream {
...
@@ -145,7 +142,7 @@ struct ZzipInputStream {
};
};
static
struct
input_stream
*
static
struct
input_stream
*
zzip_archive_open_stream
(
struct
archive_f
ile
*
file
,
zzip_archive_open_stream
(
ArchiveF
ile
*
file
,
const
char
*
pathname
,
const
char
*
pathname
,
Mutex
&
mutex
,
Cond
&
cond
,
Mutex
&
mutex
,
Cond
&
cond
,
GError
**
error_r
)
GError
**
error_r
)
...
...
src/input/ArchiveInputPlugin.cxx
View file @
f5c0b0d3
...
@@ -40,7 +40,6 @@ input_archive_open(const char *pathname,
...
@@ -40,7 +40,6 @@ input_archive_open(const char *pathname,
GError
**
error_r
)
GError
**
error_r
)
{
{
const
struct
archive_plugin
*
arplug
;
const
struct
archive_plugin
*
arplug
;
struct
archive_file
*
file
;
char
*
archive
,
*
filename
,
*
suffix
,
*
pname
;
char
*
archive
,
*
filename
,
*
suffix
,
*
pname
;
struct
input_stream
*
is
;
struct
input_stream
*
is
;
...
@@ -63,7 +62,7 @@ input_archive_open(const char *pathname,
...
@@ -63,7 +62,7 @@ input_archive_open(const char *pathname,
return
NULL
;
return
NULL
;
}
}
file
=
archive_file_open
(
arplug
,
archive
,
error_r
);
auto
file
=
archive_file_open
(
arplug
,
archive
,
error_r
);
if
(
file
==
NULL
)
{
if
(
file
==
NULL
)
{
g_free
(
pname
);
g_free
(
pname
);
return
NULL
;
return
NULL
;
...
...
test/visit_archive.cxx
View file @
f5c0b0d3
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
#include "InputInit.hxx"
#include "InputInit.hxx"
#include "ArchiveList.hxx"
#include "ArchiveList.hxx"
#include "ArchivePlugin.hxx"
#include "ArchivePlugin.hxx"
#include "ArchiveFile.hxx"
#include "ArchiveVisitor.hxx"
#include "ArchiveVisitor.hxx"
#include "fs/Path.hxx"
#include "fs/Path.hxx"
...
@@ -97,10 +98,11 @@ main(int argc, char **argv)
...
@@ -97,10 +98,11 @@ main(int argc, char **argv)
int
result
=
EXIT_SUCCESS
;
int
result
=
EXIT_SUCCESS
;
archive_f
ile
*
file
=
archive_file_open
(
plugin
,
path
.
c_str
(),
&
error
);
ArchiveF
ile
*
file
=
archive_file_open
(
plugin
,
path
.
c_str
(),
&
error
);
if
(
file
!=
nullptr
)
{
if
(
file
!=
nullptr
)
{
MyArchiveVisitor
visitor
;
MyArchiveVisitor
visitor
;
archive_file_visit
(
file
,
visitor
);
archive_file_visit
(
file
,
visitor
);
archive_file_close
(
file
);
}
else
{
}
else
{
fprintf
(
stderr
,
"%s
\n
"
,
error
->
message
);
fprintf
(
stderr
,
"%s
\n
"
,
error
->
message
);
g_error_free
(
error
);
g_error_free
(
error
);
...
...
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