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
bd6b7aa8
Commit
bd6b7aa8
authored
Jun 15, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
archive/Lookup: move to fs/LookupFile.cxx
This can be used for other purposes as well.
parent
fcf64159
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
20 additions
and
30 deletions
+20
-30
meson.build
src/archive/meson.build
+0
-1
LookupFile.cxx
src/fs/LookupFile.cxx
+3
-3
LookupFile.hxx
src/fs/LookupFile.hxx
+4
-4
meson.build
src/fs/meson.build
+1
-0
ArchiveInputPlugin.cxx
src/input/plugins/ArchiveInputPlugin.cxx
+2
-3
TestLookupFile.cxx
test/TestLookupFile.cxx
+7
-7
meson.build
test/meson.build
+3
-12
No files found.
src/archive/meson.build
View file @
bd6b7aa8
...
...
@@ -18,7 +18,6 @@ endif
archive_glue = static_library(
'archive_glue',
'ArchiveLookup.cxx',
'ArchivePlugin.cxx',
'../input/plugins/ArchiveInputPlugin.cxx',
include_directories: inc,
...
...
src/
archive/ArchiveLookup
.cxx
→
src/
fs/LookupFile
.cxx
View file @
bd6b7aa8
...
...
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "
ArchiveLookup
.hxx"
#include "
fs/
FileInfo.hxx"
#include "
LookupFile
.hxx"
#include "FileInfo.hxx"
#include "system/Error.hxx"
gcc_pure
...
...
@@ -33,7 +33,7 @@ FindSlash(PathTraitsFS::pointer_type p, size_t i) noexcept
}
ArchiveLookupResult
archive_lookup
(
Path
pathname
)
LookupFile
(
Path
pathname
)
{
PathTraitsFS
::
string
buffer
(
pathname
.
c_str
());
size_t
idx
=
buffer
.
size
();
...
...
src/
archive/ArchiveLookup
.hxx
→
src/
fs/LookupFile
.hxx
View file @
bd6b7aa8
...
...
@@ -17,10 +17,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_
ARCHIVE_LOOKUP
_HXX
#define MPD_
ARCHIVE_LOOKUP
_HXX
#ifndef MPD_
LOOKUP_FILE
_HXX
#define MPD_
LOOKUP_FILE
_HXX
#include "
fs/
AllocatedPath.hxx"
#include "AllocatedPath.hxx"
struct
ArchiveLookupResult
{
AllocatedPath
archive
=
nullptr
;
...
...
@@ -50,7 +50,7 @@ struct ArchiveLookupResult {
* Throws on error.
*/
ArchiveLookupResult
archive_lookup
(
Path
pathname
);
LookupFile
(
Path
pathname
);
#endif
src/fs/meson.build
View file @
bd6b7aa8
...
...
@@ -10,6 +10,7 @@ fs_sources = [
'List.cxx',
'StandardDirectory.cxx',
'CheckFile.cxx',
'LookupFile.cxx',
'DirectoryReader.cxx',
'io/PeekReader.cxx',
'io/FileReader.cxx',
...
...
src/input/plugins/ArchiveInputPlugin.cxx
View file @
bd6b7aa8
...
...
@@ -18,11 +18,11 @@
*/
#include "ArchiveInputPlugin.hxx"
#include "archive/ArchiveLookup.hxx"
#include "archive/ArchiveList.hxx"
#include "archive/ArchivePlugin.hxx"
#include "archive/ArchiveFile.hxx"
#include "../InputStream.hxx"
#include "fs/LookupFile.hxx"
#include "fs/Path.hxx"
#include "Log.hxx"
...
...
@@ -31,10 +31,9 @@ OpenArchiveInputStream(Path path, Mutex &mutex)
{
const
ArchivePlugin
*
arplug
;
// archive_lookup will modify pname when true is returned
ArchiveLookupResult
l
;
try
{
l
=
archive_lookup
(
path
);
l
=
LookupFile
(
path
);
if
(
l
.
archive
.
IsNull
())
{
return
nullptr
;
}
...
...
test/
test_archiv
e.cxx
→
test/
TestLookupFil
e.cxx
View file @
bd6b7aa8
#include "
archive/ArchiveLookup
.hxx"
#include "
fs/LookupFile
.hxx"
#include "util/Compiler.h"
#include <gtest/gtest.h>
...
...
@@ -8,22 +8,22 @@
TEST
(
ArchiveTest
,
Lookup
)
{
EXPECT_THROW
(
archive_lookup
(
Path
::
FromFS
(
""
)),
std
::
system_error
);
EXPECT_THROW
(
LookupFile
(
Path
::
FromFS
(
""
)),
std
::
system_error
);
EXPECT_FALSE
(
archive_lookup
(
Path
::
FromFS
(
"."
)));
EXPECT_FALSE
(
LookupFile
(
Path
::
FromFS
(
"."
)));
EXPECT_FALSE
(
archive_lookup
(
Path
::
FromFS
(
"config.h"
)));
EXPECT_FALSE
(
LookupFile
(
Path
::
FromFS
(
"config.h"
)));
EXPECT_THROW
(
archive_lookup
(
Path
::
FromFS
(
"src/foo/bar"
)),
std
::
system_error
);
EXPECT_THROW
(
LookupFile
(
Path
::
FromFS
(
"src/foo/bar"
)),
std
::
system_error
);
fclose
(
fopen
(
"dummy"
,
"w"
));
auto
result
=
archive_lookup
(
Path
::
FromFS
(
"dummy/foo/bar"
));
auto
result
=
LookupFile
(
Path
::
FromFS
(
"dummy/foo/bar"
));
EXPECT_TRUE
(
result
);
EXPECT_STREQ
(
result
.
archive
.
c_str
(),
"dummy"
);
EXPECT_STREQ
(
result
.
inside
.
c_str
(),
"foo/bar"
);
result
=
archive_lookup
(
Path
::
FromFS
(
"config.h/foo/bar"
));
result
=
LookupFile
(
Path
::
FromFS
(
"config.h/foo/bar"
));
EXPECT_TRUE
(
result
);
EXPECT_STREQ
(
result
.
archive
.
c_str
(),
"config.h"
);
EXPECT_STREQ
(
result
.
inside
.
c_str
(),
"foo/bar"
);
...
...
test/meson.build
View file @
bd6b7aa8
...
...
@@ -92,6 +92,9 @@ test('test_queue_priority', executable(
test('TestFs', executable(
'TestFs',
'TestFs.cxx',
'TestLookupFile.cxx',
'../src/Log.cxx',
'../src/LogBackend.cxx',
include_directories: inc,
dependencies: [
fs_dep,
...
...
@@ -339,18 +342,6 @@ endif
#
if archive_glue_dep.found()
test('test_archive', executable(
'test_archive',
'test_archive.cxx',
'../src/Log.cxx',
'../src/LogBackend.cxx',
include_directories: inc,
dependencies: [
archive_glue_dep,
gtest_dep,
],
))
executable(
'visit_archive',
'visit_archive.cxx',
...
...
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