Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs: handle Readdir(0) same as Readdir(< 0) #69

Merged
merged 1 commit into from
Jul 9, 2019
Merged

fs: handle Readdir(0) same as Readdir(< 0) #69

merged 1 commit into from
Jul 9, 2019

Conversation

dmitshur
Copy link
Contributor

@dmitshur dmitshur commented Jul 8, 2019

Implementations of the File.Readdir method are expected to treat
all n <= 0 values the same, returning all the os.FileInfo structures
from the directory in a single slice. This is documented at
https://godoc.org/net/http#File.Readdir and https://godoc.org/os#File.Readdir.

Previously, the n == 0 value was not being handled correctly.
This change fixes it by making it work the same as all other
negative values of n.

Add a test case for it.

Also simplify string(out.Bytes()) to just out.String() in a test.

Fixes #68.
Fixes shurcooL/httpfs#8.
Closes shurcooL/httpfs#9.

Implementations of the File.Readdir method are expected to treat
all n <= 0 values the same, returning all the os.FileInfo structures
from the directory in a single slice. This is documented at
https://godoc.org/net/http#File.Readdir and https://godoc.org/os#File.Readdir.

Previously, the n == 0 value was not being handled correctly.
This change fixes it by making it work the same as all other
negative values of n.

Add a test case for it.

Also simplify string(out.Bytes()) to just out.String() in a test.

Fixes #68.
Fixes shurcooL/httpfs#8.
Closes shurcooL/httpfs#9.
@dmitshur dmitshur changed the title fs: treat Readdir(0) same as Readdir(< 0) fs: handle Readdir(0) same as Readdir(< 0) Jul 8, 2019
@rakyll rakyll merged commit 28d0e00 into rakyll:master Jul 9, 2019
@rakyll
Copy link
Owner

rakyll commented Jul 9, 2019

Thanks!

@dmitshur
Copy link
Contributor Author

dmitshur commented Jul 9, 2019

Thanks for reviewing!

ekanna pushed a commit to ekanna/statik that referenced this pull request Sep 12, 2019
Implementations of the File.Readdir method are expected to treat
all n <= 0 values the same, returning all the os.FileInfo structures
from the directory in a single slice. This is documented at
https://godoc.org/net/http#File.Readdir and https://godoc.org/os#File.Readdir.

Previously, the n == 0 value was not being handled correctly.
This change fixes it by making it work the same as all other
negative values of n.

Add a test case for it.

Also simplify string(out.Bytes()) to just out.String() in a test.

Fixes rakyll#68.
Fixes shurcooL/httpfs#8.
Closes shurcooL/httpfs#9.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants