Documentation ¶
Index ¶
- func AddNewBar(p *mpb.Progress, file string, start time.Time) (b *mpb.Bar)
- func ByFormat(filename string) (interface{}, error)
- func CheckPath(destination, filename string) (err error)
- func DirFromFile(filename string) (dir string)
- func Extract(fileList *[]string, destDir string, numC uint32) (err error)
- func FileExists(filename string) bool
- func GetFile(file string) (f *os.File, err error)
- func GetFileCType(out *os.File) (string, error)
- func GetFileHeader(file string, l uint32) ([]byte, error)
- func GetFileName(f string) string
- func GetFormat(filename string) (interface{}, error)
- func GetHeader(r io.Reader, l uint32) (in []byte, err error)
- func IsIllegalPathError(err error) bool
- func IsSymlink(fi os.FileInfo) bool
- func Mkdir(path string, mode os.FileMode) error
- func TopLevels(paths []string) bool
- func WriteFile(destination string, in io.Reader, mode os.FileMode) (err error)
- func WriteHardlink(destination, link string) (err error)
- func WriteSymlink(destination, link string) (err error)
- type Bz2
- type Extractor
- type File
- type Format
- type Gz
- type IllegalPathError
- type MIME
- type Rar
- type ReadFakeCloser
- type Tar
- type TarGz
- type Zip
- type ZipCompressionMethod
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ByFormat ¶
Will return an new instance of the file format based on the magic numbers found in the file.
func CheckPath ¶
CheckPath confirms that the path provided has not been made to perform a traversal attack.
func DirFromFile ¶
DirFromFile returns a directory based on the filename provided to the function.
func FileExists ¶
FileExists will check for the existence of a file provided to the function as filename
func GetFileCType ¶
GetFileCType is a simplistic way of pulling out the MIMI type of a file. Does not always pull out the type, and will instead replace with application/octet-stream. Particularly when the filie is smaller than 512 bytes. As such, this should not necessarily be relied upon.
func GetFileHeader ¶
Return slice of bytes from file header
func GetFileName ¶
GetFileName will strip the the file name to extract to by removing the suffix. e.g. filename.tar becomes filename
func IsIllegalPathError ¶
func TopLevels ¶
TopLevels reads a slice of paths in, and returns true if there are multiple top-level directories.
func WriteHardlink ¶
WriteHardlink creates the hard link at the destination location.
func WriteSymlink ¶
WriteSymlink creates the symbolic link at the destination location
Types ¶
type Bz2 ¶
type Bz2 struct {
CompressionLevel int
}
func (*Bz2) CheckFormat ¶
CheckFormat will check the file sent to the function against the magic numbers for Bzip2. If the file is a Bzip2 the function will not return any error.
type Gz ¶
type Gz struct {
CompressionLevel int
}
func (*Gz) CheckFormat ¶
CheckFormat will check the file sent to the function against the magic numbers for GZip. If the file is a GZip the function will not return any error.
type IllegalPathError ¶
func (*IllegalPathError) Error ¶
func (e *IllegalPathError) Error() string
type Rar ¶
type Rar struct { MkdirAll bool // contains filtered or unexported fields }
func (*Rar) CheckFormat ¶
CheckFormat will check the file sent to the function against the magic numbers for Rar. If the file is a Rar the function will not return any error.
func (*Rar) OpenRarFile ¶
OpenRarFile will open the Rar file for reading
type ReadFakeCloser ¶
ReadFakeCloser is an io.Reader that has a no-op close method to satisfy the io.ReadCloser interface.
type Tar ¶
type Tar struct { MkdirAll bool // contains filtered or unexported fields }
func (*Tar) CheckFormat ¶
CheckFormat will check the file sent to the funcion against the magic numbers for Tar. If the file is a Tar the function will not return any error.
type TarGz ¶
TarGz compresses a tar archive
func (*TarGz) CheckFormat ¶
CheckFormat will check the file sent to the function against magic numbers for Gzip & Tar. If the file is a TarGz the function will not return any error. First will check the file contains the relevant magic number for a GZip file, and if so, will check that the file within contains the magic number for a Tar file.
type Zip ¶
type Zip struct { CompressionLevel int MkdirAll bool SeletiveCompression bool FileMethod uint16 // contains filtered or unexported fields }
func (*Zip) CheckFormat ¶
CheckFormat will check the file sent to the funcion against the magic numbers for Zip. If the file is a Zip the function will not return any error.
type ZipCompressionMethod ¶
type ZipCompressionMethod uint16
ZipCompressionMethod Compression type
const ( Store ZipCompressionMethod = 0 Deflate ZipCompressionMethod = 8 BZIP2 ZipCompressionMethod = 12 LZMA ZipCompressionMethod = 14 ZSTD ZipCompressionMethod = 93 XZ ZipCompressionMethod = 95 )
Compression methods. see https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT. Note LZMA: Disabled - because 7z isn't able to unpack ZIP+LZMA ZIP+LZMA2 archives made this way - and vice versa.