Documentation
¶
Index ¶
- Variables
- func AssertsDirectory(path string) bool
- func CanonicalTarNameForPath(p string) (string, error)
- func HasTrailingPathSeparator(path string) bool
- func PreserveTrailingDotOrSeparator(cleanedPath, originalPath string) string
- func SpecifiesCurrentDir(path string) bool
- func SplitPathDirEntry(localizedPath string) (dir, base string)
- func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error)
- type Archive
- type ArchiveReader
- type CopyInfo
- type TarOptions
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotDirectory = errors.New("not a directory") ErrDirNotExists = errors.New("no such directory") ErrCannotCopyDir = errors.New("cannot copy directory") ErrInvalidCopySource = errors.New("invalid copy source content") )
Errors used or returned by this file.
Functions ¶
func AssertsDirectory ¶
AssertsDirectory returns whether the given path is asserted to be a directory, i.e., the path ends with a trailing '/' or `/.`, assuming a path separator of `/`.
func CanonicalTarNameForPath ¶
CanonicalTarNameForPath returns platform-specific filepath to canonical posix-style path for tar archival. p is relative path.
func HasTrailingPathSeparator ¶
HasTrailingPathSeparator returns whether the given path ends with the system's path separator character.
func PreserveTrailingDotOrSeparator ¶
PreserveTrailingDotOrSeparator returns the given cleaned path (after processing using any utility functions from the path or filepath stdlib packages) and appends a trailing `/.` or `/` if its corresponding original path (from before being processed by utility functions from the path or filepath stdlib packages) ends with a trailing `/.` or `/`. If the cleaned path already ends in a `.` path segment, then another is not added. If the clean path already ends in a path separator, then another is not added.
func SpecifiesCurrentDir ¶
SpecifiesCurrentDir returns whether the given path specifies a "current directory", i.e., the last path segment is `.`.
func SplitPathDirEntry ¶
SplitPathDirEntry splits the given path between its parent directory and its basename in that directory.
func TarWithOptions ¶
func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error)
TarWithOptions creates an archive from the directory at `path`, only including files whose relative paths are included in `options.IncludeFiles` (if non-nil) or not in `options.ExcludePatterns`.
Types ¶
type Archive ¶
type Archive io.ReadCloser
Archive is a readable archive that must be closed.
func PrepareArchiveCopy ¶
func PrepareArchiveCopy(srcContent ArchiveReader, srcInfo, dstInfo CopyInfo) (dstDir string, content Archive, err error)
PrepareArchiveCopy prepares the given srcContent archive, which should contain the archived resource described by srcInfo, to the destination described by dstInfo. Returns the possibly modified content archive along with the path to the destination directory which it should be extracted to.
func TarResource ¶
TarResource archives the resource at the given sourcePath into a Tar archive. A non-nil error is returned if sourcePath does not exist or is asserted to be a directory but exists as another type of file.
This function acts as a convenient wrapper around TarWithOptions, which requires a directory as the source path. TarResource accepts either a directory or a file path and correctly sets the Tar options.