mirror of
https://github.com/go-task/task.git
synced 2026-07-09 06:55:14 +00:00
Run Taskfiles from sub/child directories (#920)
This commit is contained in:
22
internal/sysinfo/uid.go
Normal file
22
internal/sysinfo/uid.go
Normal file
@@ -0,0 +1,22 @@
|
||||
//go:build !windows
|
||||
|
||||
package sysinfo
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func Owner(path string) (int, error) {
|
||||
info, err := os.Stat(path)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
var uid int
|
||||
if stat, ok := info.Sys().(*syscall.Stat_t); ok {
|
||||
uid = int(stat.Uid)
|
||||
} else {
|
||||
uid = os.Getuid()
|
||||
}
|
||||
return uid, nil
|
||||
}
|
||||
9
internal/sysinfo/uid_win.go
Normal file
9
internal/sysinfo/uid_win.go
Normal file
@@ -0,0 +1,9 @@
|
||||
//go:build windows
|
||||
|
||||
package sysinfo
|
||||
|
||||
// NOTE: This always returns -1 since there is currently no easy way to get
|
||||
// file owner information on Windows.
|
||||
func Owner(path string) (int, error) {
|
||||
return -1, nil
|
||||
}
|
||||
Reference in New Issue
Block a user