sequential_unix.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //go:build !windows
  2. // +build !windows
  3. package sequential
  4. import "os"
  5. // Create creates the named file with mode 0666 (before umask), truncating
  6. // it if it already exists. If successful, methods on the returned
  7. // File can be used for I/O; the associated file descriptor has mode
  8. // O_RDWR.
  9. // If there is an error, it will be of type *PathError.
  10. func Create(name string) (*os.File, error) {
  11. return os.Create(name)
  12. }
  13. // Open opens the named file for reading. If successful, methods on
  14. // the returned file can be used for reading; the associated file
  15. // descriptor has mode O_RDONLY.
  16. // If there is an error, it will be of type *PathError.
  17. func Open(name string) (*os.File, error) {
  18. return os.Open(name)
  19. }
  20. // OpenFile is the generalized open call; most users will use Open
  21. // or Create instead. It opens the named file with specified flag
  22. // (O_RDONLY etc.) and perm, (0666 etc.) if applicable. If successful,
  23. // methods on the returned File can be used for I/O.
  24. // If there is an error, it will be of type *PathError.
  25. func OpenFile(name string, flag int, perm os.FileMode) (*os.File, error) {
  26. return os.OpenFile(name, flag, perm)
  27. }
  28. // CreateTemp creates a new temporary file in the directory dir
  29. // with a name beginning with prefix, opens the file for reading
  30. // and writing, and returns the resulting *os.File.
  31. // If dir is the empty string, TempFile uses the default directory
  32. // for temporary files (see os.TempDir).
  33. // Multiple programs calling TempFile simultaneously
  34. // will not choose the same file. The caller can use f.Name()
  35. // to find the pathname of the file. It is the caller's responsibility
  36. // to remove the file when no longer needed.
  37. func CreateTemp(dir, prefix string) (f *os.File, err error) {
  38. return os.CreateTemp(dir, prefix)
  39. }