archive/Lookup: pass const pointer

This commit is contained in:
Max Kellermann
2019-06-15 13:59:22 +02:00
parent 17f207ffd1
commit be79b44dc8
4 changed files with 16 additions and 35 deletions

View File

@@ -25,30 +25,22 @@
#include "../InputStream.hxx"
#include "fs/Path.hxx"
#include "Log.hxx"
#include "util/ScopeExit.hxx"
#include <string.h>
InputStreamPtr
OpenArchiveInputStream(Path path, Mutex &mutex)
{
const ArchivePlugin *arplug;
char *pname = strdup(path.c_str());
AtScopeExit(pname) {
free(pname);
};
// archive_lookup will modify pname when true is returned
ArchiveLookupResult l;
try {
l = archive_lookup(pname);
l = archive_lookup(path.c_str());
if (l.archive.IsNull()) {
return nullptr;
}
} catch (...) {
LogFormat(LogLevel::DEBUG, std::current_exception(),
"not an archive, lookup %s failed", pname);
"not an archive, lookup %s failed", path.c_str());
return nullptr;
}