Skip to content

os: add ModeIrregular flag #23878

@dsnet

Description

@dsnet

The os.FileInfo type is an interface, allowing other packages to implement it. One of the fields it returns is Mode which reports two pieces of information: 1) what the permissions are, and 2) what type of file it is. There is a helper method os.FileMode.IsRegular that reports whether the file is regular or not. Currently the only way to have IsRegular report false is to set the type to be one of the following:

  • ModeDir | ModeSymlink | ModeNamedPipe | ModeSocket | ModeDevice

For some implementations of os.FileInfo (see #22903 for an example), we want to be able to indicate that the file is not regular. However, every one of the aforementioned types to indicate non-regular are ill-suited as a general-purpose "unknown" file type.

Thus, I propose adding a ModeUnknown to serve exactly for that purpose. The ModeUnknown type carries no information other than the fact that the file is not regular.

CL/94856 is one such implementation.

\cc @bradfitz @ianlancetaylor @robpike @rsc

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions