2021-08-23 09:14:53 -04:00
|
|
|
//go:build !windows
|
2015-04-23 18:55:36 -04:00
|
|
|
// +build !windows
|
|
|
|
|
2018-02-05 16:05:59 -05:00
|
|
|
package system // import "github.com/docker/docker/pkg/system"
|
2015-04-23 18:55:36 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2015-08-26 15:37:01 -04:00
|
|
|
"path/filepath"
|
2015-04-23 18:55:36 -04:00
|
|
|
)
|
|
|
|
|
2019-08-08 05:51:00 -04:00
|
|
|
// MkdirAllWithACL is a wrapper for os.MkdirAll on unix systems.
|
2017-06-01 21:59:11 -04:00
|
|
|
func MkdirAllWithACL(path string, perm os.FileMode, sddl string) error {
|
2019-08-08 05:51:00 -04:00
|
|
|
return os.MkdirAll(path, perm)
|
2016-11-04 15:42:21 -04:00
|
|
|
}
|
|
|
|
|
2015-07-28 12:13:12 -04:00
|
|
|
// MkdirAll creates a directory named path along with any necessary parents,
|
|
|
|
// with permission specified by attribute perm for all dir created.
|
2019-08-08 05:51:00 -04:00
|
|
|
func MkdirAll(path string, perm os.FileMode) error {
|
2015-04-23 18:55:36 -04:00
|
|
|
return os.MkdirAll(path, perm)
|
|
|
|
}
|
2015-08-26 15:37:01 -04:00
|
|
|
|
|
|
|
// IsAbs is a platform-specific wrapper for filepath.IsAbs.
|
|
|
|
func IsAbs(path string) bool {
|
|
|
|
return filepath.IsAbs(path)
|
|
|
|
}
|
2016-11-01 18:44:06 -04:00
|
|
|
|
2017-01-11 18:55:43 -05:00
|
|
|
// The functions below here are wrappers for the equivalents in the os and ioutils packages.
|
2016-11-01 18:44:06 -04:00
|
|
|
// They are passthrough on Unix platforms, and only relevant on Windows.
|
|
|
|
|
|
|
|
// CreateSequential creates the named file with mode 0666 (before umask), truncating
|
|
|
|
// it if it already exists. If successful, methods on the returned
|
|
|
|
// File can be used for I/O; the associated file descriptor has mode
|
|
|
|
// O_RDWR.
|
|
|
|
// If there is an error, it will be of type *PathError.
|
|
|
|
func CreateSequential(name string) (*os.File, error) {
|
|
|
|
return os.Create(name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// OpenSequential opens the named file for reading. If successful, methods on
|
|
|
|
// the returned file can be used for reading; the associated file
|
|
|
|
// descriptor has mode O_RDONLY.
|
|
|
|
// If there is an error, it will be of type *PathError.
|
|
|
|
func OpenSequential(name string) (*os.File, error) {
|
|
|
|
return os.Open(name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// OpenFileSequential is the generalized open call; most users will use Open
|
|
|
|
// or Create instead. It opens the named file with specified flag
|
|
|
|
// (O_RDONLY etc.) and perm, (0666 etc.) if applicable. If successful,
|
|
|
|
// methods on the returned File can be used for I/O.
|
|
|
|
// If there is an error, it will be of type *PathError.
|
|
|
|
func OpenFileSequential(name string, flag int, perm os.FileMode) (*os.File, error) {
|
|
|
|
return os.OpenFile(name, flag, perm)
|
|
|
|
}
|
2017-01-11 18:55:43 -05:00
|
|
|
|
|
|
|
// TempFileSequential creates a new temporary file in the directory dir
|
|
|
|
// with a name beginning with prefix, opens the file for reading
|
|
|
|
// and writing, and returns the resulting *os.File.
|
|
|
|
// If dir is the empty string, TempFile uses the default directory
|
|
|
|
// for temporary files (see os.TempDir).
|
|
|
|
// Multiple programs calling TempFile simultaneously
|
|
|
|
// will not choose the same file. The caller can use f.Name()
|
|
|
|
// to find the pathname of the file. It is the caller's responsibility
|
|
|
|
// to remove the file when no longer needed.
|
|
|
|
func TempFileSequential(dir, prefix string) (f *os.File, err error) {
|
2021-08-24 06:10:50 -04:00
|
|
|
return os.CreateTemp(dir, prefix)
|
2017-01-11 18:55:43 -05:00
|
|
|
}
|