1// +build !windows
2
3package system // import "github.com/docker/docker/pkg/system"
4
5import (
6	"io/ioutil"
7	"os"
8	"path/filepath"
9)
10
11// MkdirAllWithACL is a wrapper for MkdirAll on unix systems.
12func MkdirAllWithACL(path string, perm os.FileMode, sddl string) error {
13	return MkdirAll(path, perm, sddl)
14}
15
16// MkdirAll creates a directory named path along with any necessary parents,
17// with permission specified by attribute perm for all dir created.
18func MkdirAll(path string, perm os.FileMode, sddl string) error {
19	return os.MkdirAll(path, perm)
20}
21
22// IsAbs is a platform-specific wrapper for filepath.IsAbs.
23func IsAbs(path string) bool {
24	return filepath.IsAbs(path)
25}
26
27// The functions below here are wrappers for the equivalents in the os and ioutils packages.
28// They are passthrough on Unix platforms, and only relevant on Windows.
29
30// CreateSequential creates the named file with mode 0666 (before umask), truncating
31// it if it already exists. If successful, methods on the returned
32// File can be used for I/O; the associated file descriptor has mode
33// O_RDWR.
34// If there is an error, it will be of type *PathError.
35func CreateSequential(name string) (*os.File, error) {
36	return os.Create(name)
37}
38
39// OpenSequential opens the named file for reading. If successful, methods on
40// the returned file can be used for reading; the associated file
41// descriptor has mode O_RDONLY.
42// If there is an error, it will be of type *PathError.
43func OpenSequential(name string) (*os.File, error) {
44	return os.Open(name)
45}
46
47// OpenFileSequential is the generalized open call; most users will use Open
48// or Create instead. It opens the named file with specified flag
49// (O_RDONLY etc.) and perm, (0666 etc.) if applicable. If successful,
50// methods on the returned File can be used for I/O.
51// If there is an error, it will be of type *PathError.
52func OpenFileSequential(name string, flag int, perm os.FileMode) (*os.File, error) {
53	return os.OpenFile(name, flag, perm)
54}
55
56// TempFileSequential creates a new temporary file in the directory dir
57// with a name beginning with prefix, opens the file for reading
58// and writing, and returns the resulting *os.File.
59// If dir is the empty string, TempFile uses the default directory
60// for temporary files (see os.TempDir).
61// Multiple programs calling TempFile simultaneously
62// will not choose the same file. The caller can use f.Name()
63// to find the pathname of the file. It is the caller's responsibility
64// to remove the file when no longer needed.
65func TempFileSequential(dir, prefix string) (f *os.File, err error) {
66	return ioutil.TempFile(dir, prefix)
67}
68