Skip to content

Commit 999dd7a

Browse files
authored
feat: add support for all upstream dist to file package (#226)
use specific function for unix goos and fallback for non-unix systems
1 parent 8ec6b25 commit 999dd7a

File tree

4 files changed

+11
-66
lines changed

4 files changed

+11
-66
lines changed

file/fileinfo.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ func Lstat(name string) (FileInfo, error) {
4343
return stat(name, os.Lstat)
4444
}
4545

46+
func stat(name string, statFunc func(name string) (os.FileInfo, error)) (FileInfo, error) {
47+
info, err := statFunc(name)
48+
if err != nil {
49+
return nil, err
50+
}
51+
52+
return wrap(info)
53+
}
54+
4655
// Wrap wraps the given os.FileInfo and returns a FileInfo in order to expose
4756
// the UID and GID in a uniform manner across operating systems.
4857
func Wrap(info os.FileInfo) (FileInfo, error) {

file/fileinfo_windows.go renamed to file/fileinfo_other.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,14 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18+
//go:build !unix
19+
1820
package file
1921

2022
import (
2123
"os"
2224
)
2325

24-
func stat(name string, statFunc func(name string) (os.FileInfo, error)) (FileInfo, error) {
25-
info, err := statFunc(name)
26-
if err != nil {
27-
return nil, err
28-
}
29-
30-
return wrap(info)
31-
}
32-
3326
func wrap(info os.FileInfo) (FileInfo, error) {
3427
return fileInfo{FileInfo: info}, nil
3528
}

file/fileinfo_plan9.go

Lines changed: 0 additions & 48 deletions
This file was deleted.

file/fileinfo_unix.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,6 @@ import (
2525
"syscall"
2626
)
2727

28-
func stat(name string, statFunc func(name string) (os.FileInfo, error)) (FileInfo, error) {
29-
info, err := statFunc(name)
30-
if err != nil {
31-
return nil, err
32-
}
33-
34-
return wrap(info)
35-
}
36-
3728
func wrap(info os.FileInfo) (FileInfo, error) {
3829
stat, ok := info.Sys().(*syscall.Stat_t)
3930
if !ok {

0 commit comments

Comments
 (0)