Skip to content

Commit

Permalink
VSIReadDirRecursive(): make it work properly with a trailing slash (e…
Browse files Browse the repository at this point in the history
…specially on /vsizip/) (fixes OSGeo#8474)
  • Loading branch information
rouault authored and craigds committed Sep 25, 2023
1 parent bb5dfb5 commit 5f19ff9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions autotest/gcore/vsizip.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ def test_vsizip_4():
"uint16.tif",
], "bad content"

# Test with trailing slash too
assert gdal.ReadDirRecursive("/vsizip/data/testzip.zip/") == res


###############################################################################
# Test ReadRecursive on deep zip
Expand Down
3 changes: 3 additions & 0 deletions port/cpl_vsil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1455,6 +1455,9 @@ VSIDIR *VSIFilesystemHandler::OpenDir(const char *pszPath, int nRecurseDepth,
}
VSIDIRGeneric *dir = new VSIDIRGeneric(this);
dir->osRootPath = pszPath;
if (!dir->osRootPath.empty() &&
(dir->osRootPath.back() == '/' || dir->osRootPath.back() == '\\'))
dir->osRootPath.pop_back();
dir->nRecurseDepth = nRecurseDepth;
dir->papszContent = papszContent;
dir->m_osFilterPrefix = CSLFetchNameValueDef(papszOptions, "PREFIX", "");
Expand Down

0 comments on commit 5f19ff9

Please sign in to comment.