archive

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2015 License: Apache-2.0 Imports: 16 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func AssertsDirectory(path string) bool

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

func CanonicalTarNameForPath(p string) (string, error)

CanonicalTarNameForPath returns platform-specific filepath to canonical posix-style path for tar archival. p is relative path.

func HasTrailingPathSeparator

func HasTrailingPathSeparator(path string) bool

HasTrailingPathSeparator returns whether the given path ends with the system's path separator character.

func PreserveTrailingDotOrSeparator

func PreserveTrailingDotOrSeparator(cleanedPath, originalPath string) string

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

func SpecifiesCurrentDir(path string) bool

SpecifiesCurrentDir returns whether the given path specifies a "current directory", i.e., the last path segment is `.`.

func SplitPathDirEntry

func SplitPathDirEntry(localizedPath string) (dir, base string)

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

func TarResource(sourcePath string) (content Archive, err error)

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.

type ArchiveReader

type ArchiveReader io.Reader

ArchiveReader is a readabel archive.

type CopyInfo

type CopyInfo struct {
	Path   string
	Exists bool
	IsDir  bool
}

CopyInfo holds basic info about the source or destination path of a copy operation.

func CopyInfoStatPath

func CopyInfoStatPath(path string, mustExist bool) (CopyInfo, error)

CopyInfoStatPath stats the given path to create a CopyInfo struct representing that resource. If mustExist is true, then it is an error if there is no file or directory at the given path.

type TarOptions

type TarOptions struct {
	IncludeFiles     []string
	ExcludePatterns  []string
	NoLchown         bool
	Name             string
	IncludeSourceDir bool
}

TarOptions specifis all the options to archive files and directories.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL