Documentation ¶
Index ¶
- func Decoder(name string, current io.Reader) (string, io.Reader, error)
- func MkdirAll(dir string, perm os.FileMode) ([]string, error)
- func Untar(r io.Reader, dir string, mods ...Modifier) error
- func Untarz(name string, r io.Reader, dest string, mods ...Modifier) error
- type Modifier
- type Modifiers
- type TempUnzipDir
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MkdirAll ¶
MkdirAll is just like os.MkdirAll, except it returns the set of directories created.
func Untar ¶
Untar opens a .tar file (no compression), and unpacks it in the specified directory.
Untar can only create regular files, symlinks, and directories. The presence of any other kind of file in the archive will cause the opening to fail.
Except for targets of symlinks, if the tar contains files named like '../../../', they won't be allowed to escape the unpack directory: all unpacked files will be placed in a subdirectory of dir, no matter what.
Types ¶
type Modifier ¶
type Modifier func(*options)
func WithDefaultDirMode ¶
WithDefaultDirMode sets the privileges to use to create unknown directories.
Tar files normally contain directory and file definitions, with files in sub directories always appearing after the definition of the directory they appear in.
However, this is not mandated. There can be tar files that define files, but not the directories. Or where the directory definition is after the file definition.
WithDefaultDirMode defines the mode to use to create directories that are necessary to unpack a file, but for which a definition has not been seen in the tar yet.
If a definition is seen later on while unpacking the file, that definition will be used, and the privileges here will only be temporarily used. If a definition is not seen, the privileges here will be the final ones.
func WithDirUmask ¶
WithDirUmask sets an umask for written directories.
The default dir umask is 0, meaning that whatever is set in the .tar file will actually be used.
For example: WithDirUmask(0222) will result in no dir being writable.
func WithFileUmask ¶
WithFileUmask sets an umask for written files.
The default file umask is 0, meaning that whatever is set in the .tar file will actually be used.
For example: WithFileUmask(0222) will result in no file being writable.
type TempUnzipDir ¶
type TempUnzipDir struct {
// contains filtered or unexported fields
}
TempUnzipDir wraps a path to a temp directory that contains the contents of an unzipped archive.
func Unzip ¶
func Unzip(ctx context.Context, zipPath string) (*TempUnzipDir, error)
Unzip unzips the supplied ZIP file to a temp directory, returning a handle to the unzipped archive. This handle should be closed when the file contents are no longer in-use.
func (*TempUnzipDir) Close ¶
func (d *TempUnzipDir) Close() error
Close deletes the underlying temporary directory.
func (*TempUnzipDir) Path ¶
func (d *TempUnzipDir) Path(relPath string) string
Path returns an absolute path to a file on disk for a path relative to the root of the archive.
func (*TempUnzipDir) Root ¶
func (d *TempUnzipDir) Root() string
Root returns the path to the temporary directory, which is the root of the unzipped archive.