archive/Lookup: move to fs/LookupFile.cxx

This can be used for other purposes as well.
This commit is contained in:
Max Kellermann
2019-06-15 14:26:26 +02:00
parent fcf6415963
commit bd6b7aa88e
8 changed files with 43 additions and 53 deletions

View File

@@ -18,7 +18,6 @@ endif
archive_glue = static_library(
'archive_glue',
'ArchiveLookup.cxx',
'ArchivePlugin.cxx',
'../input/plugins/ArchiveInputPlugin.cxx',
include_directories: inc,

View File

@@ -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();

View File

@@ -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

View File

@@ -10,6 +10,7 @@ fs_sources = [
'List.cxx',
'StandardDirectory.cxx',
'CheckFile.cxx',
'LookupFile.cxx',
'DirectoryReader.cxx',
'io/PeekReader.cxx',
'io/FileReader.cxx',

View File

@@ -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;
}