From: Joe Tsai Date: Thu, 30 Nov 2017 01:11:45 +0000 (-0800) Subject: os: add ModeIrregular flag X-Git-Tag: go1.11beta1~1042 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=dfd7f3562645ebd587d7d883bbaa8915fcf8c84b;p=gostls13.git os: add ModeIrregular flag There is currently no way for os.FileMode.IsRegular to report false without being one of the following types: ModeDir | ModeSymlink | ModeNamedPipe | ModeSocket | ModeDevice This makes it difficult for custom implementations of os.FileInfo to return a Mode that is explicitly not regular without resorting to setting one of the types listed above. However, every one of the aforementioned types are ill-suited as a general-purpose "not regular" file type. Thus, add a ModeIrregular to serve exactly for that purpose. The ModeIrregular type carries no information other than the fact that the file is not regular. Updates #22903 Fixes #23878 Change-Id: I4f34d88f960bcb014816d8e7b5de8b1035077948 Reviewed-on: https://go-review.googlesource.com/94856 Reviewed-by: Brad Fitzpatrick --- diff --git a/src/os/types.go b/src/os/types.go index db7848759c..b0b7d8d94d 100644 --- a/src/os/types.go +++ b/src/os/types.go @@ -54,15 +54,16 @@ const ( ModeSetgid // g: setgid ModeCharDevice // c: Unix character device, when ModeDevice is set ModeSticky // t: sticky + ModeIrregular // ?: non-regular file; nothing else is known about this file // Mask for the type bits. For regular files, none will be set. - ModeType = ModeDir | ModeSymlink | ModeNamedPipe | ModeSocket | ModeDevice + ModeType = ModeDir | ModeSymlink | ModeNamedPipe | ModeSocket | ModeDevice | ModeIrregular ModePerm FileMode = 0777 // Unix permission bits ) func (m FileMode) String() string { - const str = "dalTLDpSugct" + const str = "dalTLDpSugct?" var buf [32]byte // Mode is uint32. w := 0 for i, c := range str {