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
2e0949d8
Commit
2e0949d8
authored
Dec 27, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
archive/Plugin: return std::unique_ptr<ArchiveFile>
parent
5a728a06
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
16 additions
and
20 deletions
+16
-20
ArchivePlugin.cxx
src/archive/ArchivePlugin.cxx
+2
-1
ArchivePlugin.hxx
src/archive/ArchivePlugin.hxx
+4
-2
Bzip2ArchivePlugin.cxx
src/archive/plugins/Bzip2ArchivePlugin.cxx
+2
-2
Iso9660ArchivePlugin.cxx
src/archive/plugins/Iso9660ArchivePlugin.cxx
+2
-2
ZzipArchivePlugin.cxx
src/archive/plugins/ZzipArchivePlugin.cxx
+2
-2
Archive.cxx
src/db/update/Archive.cxx
+1
-2
ArchiveInputPlugin.cxx
src/input/plugins/ArchiveInputPlugin.cxx
+2
-7
visit_archive.cxx
test/visit_archive.cxx
+1
-2
No files found.
src/archive/ArchivePlugin.cxx
View file @
2e0949d8
...
@@ -19,11 +19,12 @@
...
@@ -19,11 +19,12 @@
#include "config.h"
#include "config.h"
#include "ArchivePlugin.hxx"
#include "ArchivePlugin.hxx"
#include "ArchiveFile.hxx"
#include "fs/Path.hxx"
#include "fs/Path.hxx"
#include <assert.h>
#include <assert.h>
ArchiveFile
*
std
::
unique_ptr
<
ArchiveFile
>
archive_file_open
(
const
ArchivePlugin
*
plugin
,
Path
path
)
archive_file_open
(
const
ArchivePlugin
*
plugin
,
Path
path
)
{
{
assert
(
plugin
!=
nullptr
);
assert
(
plugin
!=
nullptr
);
...
...
src/archive/ArchivePlugin.hxx
View file @
2e0949d8
...
@@ -20,6 +20,8 @@
...
@@ -20,6 +20,8 @@
#ifndef MPD_ARCHIVE_PLUGIN_HXX
#ifndef MPD_ARCHIVE_PLUGIN_HXX
#define MPD_ARCHIVE_PLUGIN_HXX
#define MPD_ARCHIVE_PLUGIN_HXX
#include <memory>
class
ArchiveFile
;
class
ArchiveFile
;
class
Path
;
class
Path
;
...
@@ -45,7 +47,7 @@ struct ArchivePlugin {
...
@@ -45,7 +47,7 @@ struct ArchivePlugin {
*
*
* Throws std::runtime_error on error.
* Throws std::runtime_error on error.
*/
*/
ArchiveFile
*
(
*
open
)(
Path
path_fs
);
std
::
unique_ptr
<
ArchiveFile
>
(
*
open
)(
Path
path_fs
);
/**
/**
* suffixes handled by this plugin.
* suffixes handled by this plugin.
...
@@ -54,7 +56,7 @@ struct ArchivePlugin {
...
@@ -54,7 +56,7 @@ struct ArchivePlugin {
const
char
*
const
*
suffixes
;
const
char
*
const
*
suffixes
;
};
};
ArchiveFile
*
std
::
unique_ptr
<
ArchiveFile
>
archive_file_open
(
const
ArchivePlugin
*
plugin
,
Path
path
);
archive_file_open
(
const
ArchivePlugin
*
plugin
,
Path
path
);
#endif
#endif
src/archive/plugins/Bzip2ArchivePlugin.cxx
View file @
2e0949d8
...
@@ -102,13 +102,13 @@ Bzip2InputStream::Open()
...
@@ -102,13 +102,13 @@ Bzip2InputStream::Open()
/* archive open && listing routine */
/* archive open && listing routine */
static
ArchiveFile
*
static
std
::
unique_ptr
<
ArchiveFile
>
bz2_open
(
Path
pathname
)
bz2_open
(
Path
pathname
)
{
{
static
Mutex
mutex
;
static
Mutex
mutex
;
static
Cond
cond
;
static
Cond
cond
;
auto
is
=
OpenLocalInputStream
(
pathname
,
mutex
,
cond
);
auto
is
=
OpenLocalInputStream
(
pathname
,
mutex
,
cond
);
return
new
Bzip2ArchiveFile
(
pathname
,
std
::
move
(
is
));
return
std
::
make_unique
<
Bzip2ArchiveFile
>
(
pathname
,
std
::
move
(
is
));
}
}
/* single archive handling */
/* single archive handling */
...
...
src/archive/plugins/Iso9660ArchivePlugin.cxx
View file @
2e0949d8
...
@@ -116,10 +116,10 @@ Iso9660ArchiveFile::Visit(char *path, size_t length, size_t capacity,
...
@@ -116,10 +116,10 @@ Iso9660ArchiveFile::Visit(char *path, size_t length, size_t capacity,
_cdio_list_free
(
entlist
,
true
);
_cdio_list_free
(
entlist
,
true
);
}
}
static
ArchiveFile
*
static
std
::
unique_ptr
<
ArchiveFile
>
iso9660_archive_open
(
Path
pathname
)
iso9660_archive_open
(
Path
pathname
)
{
{
return
new
Iso9660ArchiveFile
(
std
::
make_shared
<
Iso9660
>
(
pathname
));
return
std
::
make_unique
<
Iso9660ArchiveFile
>
(
std
::
make_shared
<
Iso9660
>
(
pathname
));
}
}
void
void
...
...
src/archive/plugins/ZzipArchivePlugin.cxx
View file @
2e0949d8
...
@@ -65,10 +65,10 @@ public:
...
@@ -65,10 +65,10 @@ public:
/* archive open && listing routine */
/* archive open && listing routine */
static
ArchiveFile
*
static
std
::
unique_ptr
<
ArchiveFile
>
zzip_archive_open
(
Path
pathname
)
zzip_archive_open
(
Path
pathname
)
{
{
return
new
ZzipArchiveFile
(
std
::
make_shared
<
ZzipDir
>
(
pathname
));
return
std
::
make_unique
<
ZzipArchiveFile
>
(
std
::
make_shared
<
ZzipDir
>
(
pathname
));
}
}
inline
void
inline
void
...
...
src/db/update/Archive.cxx
View file @
2e0949d8
...
@@ -150,7 +150,7 @@ UpdateWalk::UpdateArchiveFile(Directory &parent, const char *name,
...
@@ -150,7 +150,7 @@ UpdateWalk::UpdateArchiveFile(Directory &parent, const char *name,
return
;
return
;
/* open archive */
/* open archive */
ArchiveFile
*
file
;
std
::
unique_ptr
<
ArchiveFile
>
file
;
try
{
try
{
file
=
archive_file_open
(
&
plugin
,
path_fs
);
file
=
archive_file_open
(
&
plugin
,
path_fs
);
}
catch
(...)
{
}
catch
(...)
{
...
@@ -177,7 +177,6 @@ UpdateWalk::UpdateArchiveFile(Directory &parent, const char *name,
...
@@ -177,7 +177,6 @@ UpdateWalk::UpdateArchiveFile(Directory &parent, const char *name,
UpdateArchiveVisitor
visitor
(
*
this
,
*
file
,
directory
);
UpdateArchiveVisitor
visitor
(
*
this
,
*
file
,
directory
);
file
->
Visit
(
visitor
);
file
->
Visit
(
visitor
);
delete
file
;
}
}
bool
bool
...
...
src/input/plugins/ArchiveInputPlugin.cxx
View file @
2e0949d8
...
@@ -60,13 +60,8 @@ OpenArchiveInputStream(Path path, Mutex &mutex, Cond &cond)
...
@@ -60,13 +60,8 @@ OpenArchiveInputStream(Path path, Mutex &mutex, Cond &cond)
return
nullptr
;
return
nullptr
;
}
}
auto
file
=
archive_file_open
(
arplug
,
Path
::
FromFS
(
archive
));
return
archive_file_open
(
arplug
,
Path
::
FromFS
(
archive
))
->
OpenStream
(
filename
,
mutex
,
cond
);
AtScopeExit
(
file
)
{
delete
file
;
};
return
file
->
OpenStream
(
filename
,
mutex
,
cond
);
}
}
static
InputStreamPtr
static
InputStreamPtr
...
...
test/visit_archive.cxx
View file @
2e0949d8
...
@@ -89,11 +89,10 @@ try {
...
@@ -89,11 +89,10 @@ try {
int
result
=
EXIT_SUCCESS
;
int
result
=
EXIT_SUCCESS
;
ArchiveFile
*
file
=
archive_file_open
(
plugin
,
path
);
auto
file
=
archive_file_open
(
plugin
,
path
);
MyArchiveVisitor
visitor
;
MyArchiveVisitor
visitor
;
file
->
Visit
(
visitor
);
file
->
Visit
(
visitor
);
delete
file
;
return
result
;
return
result
;
}
catch
(
const
std
::
exception
&
e
)
{
}
catch
(
const
std
::
exception
&
e
)
{
...
...
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