implement Fileinfo for Windows and non-Windows
This commit is contained in:
committed by
Ben Johnson
parent
e9dbf83a45
commit
4522c7bce5
@@ -176,15 +176,6 @@ func MkdirAll(path string, mode os.FileMode, uid, gid int) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fileinfo returns syscall fields from a FileInfo object.
|
|
||||||
func Fileinfo(fi os.FileInfo) (uid, gid int) {
|
|
||||||
if fi == nil {
|
|
||||||
return -1, -1
|
|
||||||
}
|
|
||||||
stat := fi.Sys().(*syscall.Stat_t)
|
|
||||||
return int(stat.Uid), int(stat.Gid)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ParseSnapshotPath parses the index from a snapshot filename. Used by path-based replicas.
|
// ParseSnapshotPath parses the index from a snapshot filename. Used by path-based replicas.
|
||||||
func ParseSnapshotPath(s string) (index int, err error) {
|
func ParseSnapshotPath(s string) (index int, err error) {
|
||||||
a := snapshotPathRegex.FindStringSubmatch(s)
|
a := snapshotPathRegex.FindStringSubmatch(s)
|
||||||
|
|||||||
17
internal/internal_unix.go
Normal file
17
internal/internal_unix.go
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
//go:build !windows
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Fileinfo returns syscall fields from a FileInfo object.
|
||||||
|
func Fileinfo(fi os.FileInfo) (uid, gid int) {
|
||||||
|
if fi == nil {
|
||||||
|
return -1, -1
|
||||||
|
}
|
||||||
|
stat := fi.Sys().(*syscall.Stat_t)
|
||||||
|
return int(stat.Uid), int(stat.Gid)
|
||||||
|
}
|
||||||
12
internal/internal_windows.go
Normal file
12
internal/internal_windows.go
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
//go:build windows
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Fileinfo returns syscall fields from a FileInfo object.
|
||||||
|
func Fileinfo(fi os.FileInfo) (uid, gid int) {
|
||||||
|
return -1, -1
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user