Skip to content

os: FileInfo.Sys should return underlying data source on Windows #9611

@perillo

Description

@perillo

The documentation of the Sys method for the FileInfo interface says:
"underlying data source (can return nil)"

However the Windows implementation does not do this.

The underlying data source for the FileInfo implementation in the Stat function is
syscall.ByHandleFileInformation, however the Sys method returns syscall.Win32FileAttributeData.

The underlying data source for the FileInfo implementation in the Readdir method is syscall.Win32finddata, however the Sys method returns syscall.Win32FleAttributeData.

The advantage of the current implementation is that Sys returns the same dynamic type, as it is done on Unix systems. However the disadvantage is that some valuable information (VolumeInformation and FineIndex from the Stat call) is thrown away. The current implementation also has to allocate additional space.

Since the interface documentation seems to allow it, I propose that the Sys method returns the actual underlying data used by the implementation, ad discussed above.

The change does not break the go 1 compatibility promise.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions