basicfs_fileinfo_unix.go 838 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright (C) 2017 The Syncthing Authors.
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. // You can obtain one at https://mozilla.org/MPL/2.0/.
  6. //go:build !windows
  7. // +build !windows
  8. package fs
  9. import (
  10. "os"
  11. "syscall"
  12. )
  13. func (e basicFileInfo) Mode() FileMode {
  14. return FileMode(e.FileInfo.Mode())
  15. }
  16. func (e basicFileInfo) Owner() int {
  17. if st, ok := e.Sys().(*syscall.Stat_t); ok {
  18. return int(st.Uid)
  19. }
  20. return -1
  21. }
  22. func (e basicFileInfo) Group() int {
  23. if st, ok := e.Sys().(*syscall.Stat_t); ok {
  24. return int(st.Gid)
  25. }
  26. return -1
  27. }
  28. // fileStat converts e to os.FileInfo that is suitable
  29. // to be passed to os.SameFile. Non-trivial on Windows.
  30. func (e *basicFileInfo) osFileInfo() os.FileInfo {
  31. return e.FileInfo
  32. }