-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Remove FileInfo.path #1770
Comments
Also why do we have both Lines 30 to 34 in e782ba1
|
Isn't it like this?
|
That seems like something people can compute themselves. We shouldn't be doing more than the minimal amount of work. Note the structure of https://golang.org/pkg/os/#FileInfo |
Golang basically removes leading directory and trailing slashes from |
As @GrosSacASac pointed out in Gitter, these could be memoized getters, so the first time they are accessed they are calced/retrieved and stored. Of course it maybe just better to have them as functions and people then understand there is some sort of cost to retrieving them. It is certainly doable with getters, but users don't consciously realise there is a cost. |
I think we can stub both these in on both stat and lstat calls, since we're passed the filename (.path) and can take the .name from that too. |
I personally prefer retaining the Meanwhile, given that #1774 was closed without getting merged, it seems like the conclusion is (unfortunately) already made that we're removing these properties from |
Unfortunately I think this logic needs to be moved to something in std. I don't really understand @ry's decision as I think it's useful, trivial and without perf impact, but looks like this convenience needs to be wrapped around every fs function in std (with a FileInfo type defined there which includes both path/name fields). 🙄 |
FileInfo doesn't need both the base name and the path. It's redundant. If you want to have Stat copy the base name into the FileInfo, I'd be fine with that. But first, FileInfo.path needs to be removed. |
I thought If things are not like this (it seems like so), I'm totally convinced that FileInfo.path can be removed. |
I am removing |
Discussion from gitter chat.
Calls to
stat
andlstat
returnFileInfo
withnull
values forname
andpath
.Call to
readDir
returnsFileInfo[]
withname
andpath
filled.stat
does not return values for those two fields, which might lead to confusion down the road. It'd be better not to do additional syscall duringstat
.CC @ry
The text was updated successfully, but these errors were encountered: