1
0
mirror of https://github.com/golang/go synced 2024-11-05 17:36:15 -07:00
go/godoc/vfs
Joe Henke 5bc19071d3 godoc/vfs/zipfs: add tests; fix handling of "/"
- add tests for Open, ReadDir, and Stat funcs
- add tests for Seek of Open()
- simplify internal handling of absolute vs. "zip" paths
- fix handling of "/"

The fix special cases this scenario, leaving the codepath for all
other file paths the same. Specifically,

- Exported funcs call stat(), so stat("/") is handled by simply
returning 0 to indicate all entries are (effectively) prefixed
by "/" and zipFI{"", nil} because "/" has no name and nil
indicates it is a directory.

- ReadDir("/") is further handled by seeding the existing lookup
logic with "" instead of what would have been "/". This is
necessary because, per the zipfs spec, the zip file entries MUST
NOT start with "/", so using "/" would incorrectly match nothing.
This works because seeding lookup with "" (correctly) matches
all files and then the following, existing logic (correctly) pares
things down to just the files in the root directory; not in any
subdirectories.

Verified that godoc -zip still works.

Fixes golang/go#12743

Change-Id: Icb5f01b8a29cefa4e2820135f318894042970301
Reviewed-on: https://go-review.googlesource.com/16925
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-11-17 21:45:41 +00:00
..
gatefs tools: add import comments. 2014-12-09 22:42:16 +00:00
httpfs tools: add import comments. 2014-12-09 22:42:16 +00:00
mapfs tools: add import comments. 2014-12-09 22:42:16 +00:00
zipfs godoc/vfs/zipfs: add tests; fix handling of "/" 2015-11-17 21:45:41 +00:00
namespace.go go.tools/godoc: move vfs code to vfs package 2013-07-17 15:02:27 +10:00
os.go godoc/vfs: close file on error 2015-06-01 03:28:17 +00:00
vfs.go tools: add import comments. 2014-12-09 22:42:16 +00:00