basicfs_fileinfo_unix.go 818 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. // +build !windows
  7. package fs
  8. import (
  9. "os"
  10. "syscall"
  11. )
  12. func (e basicFileInfo) Mode() FileMode {
  13. return FileMode(e.FileInfo.Mode())
  14. }
  15. func (e basicFileInfo) Owner() int {
  16. if st, ok := e.Sys().(*syscall.Stat_t); ok {
  17. return int(st.Uid)
  18. }
  19. return -1
  20. }
  21. func (e basicFileInfo) Group() int {
  22. if st, ok := e.Sys().(*syscall.Stat_t); ok {
  23. return int(st.Gid)
  24. }
  25. return -1
  26. }
  27. // fileStat converts e to os.FileInfo that is suitable
  28. // to be passed to os.SameFile. Non-trivial on Windows.
  29. func (e *basicFileInfo) osFileInfo() os.FileInfo {
  30. return e.FileInfo
  31. }