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