filesys.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // +build !windows
  2. package system
  3. import (
  4. "os"
  5. "path/filepath"
  6. )
  7. // MkdirAllWithACL is a wrapper for MkdirAll that creates a directory
  8. // ACL'd for Builtin Administrators and Local System.
  9. func MkdirAllWithACL(path string, perm os.FileMode) error {
  10. return MkdirAll(path, perm)
  11. }
  12. // MkdirAll creates a directory named path along with any necessary parents,
  13. // with permission specified by attribute perm for all dir created.
  14. func MkdirAll(path string, perm os.FileMode) error {
  15. return os.MkdirAll(path, perm)
  16. }
  17. // IsAbs is a platform-specific wrapper for filepath.IsAbs.
  18. func IsAbs(path string) bool {
  19. return filepath.IsAbs(path)
  20. }
  21. // The functions below here are wrappers for the equivalents in the os package.
  22. // They are passthrough on Unix platforms, and only relevant on Windows.
  23. // CreateSequential creates the named file with mode 0666 (before umask), truncating
  24. // it if it already exists. If successful, methods on the returned
  25. // File can be used for I/O; the associated file descriptor has mode
  26. // O_RDWR.
  27. // If there is an error, it will be of type *PathError.
  28. func CreateSequential(name string) (*os.File, error) {
  29. return os.Create(name)
  30. }
  31. // OpenSequential opens the named file for reading. If successful, methods on
  32. // the returned file can be used for reading; the associated file
  33. // descriptor has mode O_RDONLY.
  34. // If there is an error, it will be of type *PathError.
  35. func OpenSequential(name string) (*os.File, error) {
  36. return os.Open(name)
  37. }
  38. // OpenFileSequential is the generalized open call; most users will use Open
  39. // or Create instead. It opens the named file with specified flag
  40. // (O_RDONLY etc.) and perm, (0666 etc.) if applicable. If successful,
  41. // methods on the returned File can be used for I/O.
  42. // If there is an error, it will be of type *PathError.
  43. func OpenFileSequential(name string, flag int, perm os.FileMode) (*os.File, error) {
  44. return os.OpenFile(name, flag, perm)
  45. }