Skip to content

Commit

Permalink
Bugfix accessing zip paths with no characters after the hash (#18894)
Browse files Browse the repository at this point in the history
Add passthrough of openNextFile, so that folders can be opened and read via the ZipFS proxied filesystems.
  • Loading branch information
btsimonh authored Jun 18, 2023
1 parent 4452228 commit b2fd311
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/libesp32/Zip-readonly-FS/src/ZipReadFS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ class ZipEntryFileImpl : public FileImpl {
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; }
Expand Down Expand Up @@ -163,7 +165,9 @@ class ZipReadFileImpl : public FileImpl {
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();
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit b2fd311

Please sign in to comment.