github.com/jingleWang/moby@v1.13.1/pkg/system/filesys.go (about)

     1  // +build !windows
     2  
     3  package system
     4  
     5  import (
     6  	"os"
     7  	"path/filepath"
     8  )
     9  
    10  // MkdirAllWithACL is a wrapper for MkdirAll that creates a directory
    11  // ACL'd for Builtin Administrators and Local System.
    12  func MkdirAllWithACL(path string, perm os.FileMode) error {
    13  	return MkdirAll(path, perm)
    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.
    18  func MkdirAll(path string, perm os.FileMode) error {
    19  	return os.MkdirAll(path, perm)
    20  }
    21  
    22  // IsAbs is a platform-specific wrapper for filepath.IsAbs.
    23  func IsAbs(path string) bool {
    24  	return filepath.IsAbs(path)
    25  }
    26  
    27  // The functions below here are wrappers for the equivalents in the os package.
    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.
    35  func 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.
    43  func 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.
    52  func OpenFileSequential(name string, flag int, perm os.FileMode) (*os.File, error) {
    53  	return os.OpenFile(name, flag, perm)
    54  }