-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
os: no direct access to file access time #3952
Labels
Comments
The access time is not available because the Windows os.Stat does not return it. I don't know Windows at all. If the Windows Stat can return it, then we can add AccTime to the FileInfo interface. Otherwise it will need to be system dependent per previous comment. Labels changed: added os-windows. |
I could be wrong, but the access time should be available on windows. In fact, looking at the code, we already have func atime(fi FileInfo) time.Time implemented in os. It is used for os tests only, but we could expose this functionality. If someone wants to suggest the interface, I am happy to implement and test windows side of things. Alex |
Plenty of systems don't support access time. I believe that is why it is not part of the FileInfo API. We cannot add anything to os.FileInfo, because of the Go 1 promise. The idea is that if you care, you use .Sys() and then you know you're doing something system-specific. Status changed to WorkingAsIntended. |
I think having .Sys() on windows work as similar as possible to the other platforms would be ideal. Looking at the code though, that looks to be a bit complicated. It looks like FileInfo.Sys() from a FileInfo returned by os.Stat could easily return a syscall.Win32FileAttributeData, however, File.Stat would need to use a syscall.ByHandleFileInformation. As this is a platform specific implementation detail, I would not be opposed to Sys() returning either, and the caller being responsible for determining if its supposed to be a Win32FileAttributeData or ByHandleFileInformation via reflect or the like. Does something else make more sense? |
> I think having .Sys() on windows work as similar as possible to the other platforms would be ideal. How so? For example, it looks like this on linux: type Stat_t struct { Dev uint64 X__pad1 uint16 Pad_cgo_0 [2]byte X__st_ino uint32 Mode uint32 Nlink uint32 Uid uint32 Gid uint32 Rdev uint64 X__pad2 uint16 Pad_cgo_1 [2]byte Size int64 Blksize int32 Blocks int64 Atim Timespec Mtim Timespec Ctim Timespec Ino uint64 } Do you want it all on windows? I do not think so. > It looks like FileInfo.Sys() from a FileInfo returned by os.Stat could easily ... Lets not design things here. Just tell use what you need. What is your problem? Once we know what your problem is, then, perhaps, we can decide how to help you. Thank you. Alex |
Moving discussion here https://golang.org/issue/4569 Alex |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by coolaj86:
The text was updated successfully, but these errors were encountered: