ZipInputAccessor: Fix root directory handling

This commit is contained in:
Eelco Dolstra 2022-02-25 13:19:07 +01:00
parent 1d36d16086
commit 08fc769d2c

View file

@ -81,13 +81,18 @@ struct ZipInputAccessor : InputAccessor
bool pathExists(PathView _path) override bool pathExists(PathView _path) override
{ {
auto path = canonPath(_path); auto path = canonPath(_path);
return members.find(((std::string) path).c_str()) != members.end(); return
members.find(((std::string) path).c_str()) != members.end()
|| members.find(((std::string) path + "/").c_str()) != members.end();
} }
Stat lstat(PathView _path) override Stat lstat(PathView _path) override
{ {
auto path = canonPath(_path); auto path = canonPath(_path);
if (path == "/")
return Stat { .type = tDirectory };
Type type = tRegular; Type type = tRegular;
bool isExecutable = false; bool isExecutable = false;
@ -126,7 +131,8 @@ struct ZipInputAccessor : InputAccessor
DirEntries readDirectory(PathView _path) override DirEntries readDirectory(PathView _path) override
{ {
auto path = canonPath(_path) + "/"; auto path = canonPath(_path);
if (path != "/") path += "/";
auto i = members.find(((std::string) path).c_str()); auto i = members.find(((std::string) path).c_str());
if (i == members.end()) if (i == members.end())