Bugfix accessing zip paths with no characters after the hash (#18894)

Add passthrough of openNextFile, so that folders can be opened and read via the ZipFS proxied filesystems.
This commit is contained in:
btsimonh 2023-06-18 17:42:39 +01:00 committed by GitHub
parent 4452228dca
commit b2fd311186
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -125,6 +125,8 @@ protected:
class ZipReadFileImpl;
typedef std::shared_ptr<FileImpl> ZipReadFileImplPtr;
// this is the proxy FileImpl - used for passing through real files.
class ZipReadFileImpl : public FileImpl {
public:
ZipReadFileImpl(File f) { _f = f; }
@ -163,7 +165,9 @@ public:
return _f.isDirectory();
}
FileImplPtr openNextFile(const char* mode) {
return nullptr; // TODO
File f = _f.openNextFile(mode);
return ZipReadFileImplPtr(new ZipReadFileImpl(f));
//return nullptr; // TODO
}
void rewindDirectory(void) {
return _f.rewindDirectory();
@ -469,6 +473,9 @@ FileImplPtr ZipReadFSImpl::open(const char* path, const char* mode, const bool c
char *tok;
char *prefix = strtok_r(sub_path, "#", &tok);
char *suffix = strtok_r(NULL, "", &tok);
if (!suffix || *suffix == 0){ // bad filename - nothing after #
return ZipReadFileImplPtr(); // return an error
}
// if suffix starts with '/', skip the first char
if (*suffix == '/') { suffix++; }
// AddLog(LOG_LEVEL_DEBUG, "ZIP: prefix=%s suffix=%s", prefix, suffix);