mirror of https://github.com/1Panel-dev/1Panel
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
418 B
28 lines
418 B
2 years ago
|
package files
|
||
|
|
||
|
import (
|
||
|
"os"
|
||
|
"os/user"
|
||
|
"strconv"
|
||
|
)
|
||
|
|
||
|
func IsSymlink(mode os.FileMode) bool {
|
||
|
return mode&os.ModeSymlink != 0
|
||
|
}
|
||
|
|
||
|
func GetUsername(uid uint32) string {
|
||
|
usr, err := user.LookupId(strconv.Itoa(int(uid)))
|
||
|
if err != nil {
|
||
|
return ""
|
||
|
}
|
||
|
return usr.Username
|
||
|
}
|
||
|
|
||
|
func GetGroup(gid uint32) string {
|
||
|
usr, err := user.LookupGroupId(strconv.Itoa(int(gid)))
|
||
|
if err != nil {
|
||
|
return ""
|
||
|
}
|
||
|
return usr.Name
|
||
|
}
|