Documentation
¶
Overview ¶
Package zip7 provides methods for working with 7z archives (p7zip wrapper)
Index ¶
Examples ¶
Constants ¶
View Source
const ( TYPE_7Z = "7z" TYPE_ZIP = "zip" TYPE_GZIP = "gzip" TYPE_XZ = "xz" TYPE_BZIP = "bzip2" )
List of supported formats
Variables ¶
This section is empty.
Functions ¶
func Add ¶
Add adds file or files to archive
Example ¶
input := "log.txt" output := "log.7z" out, err := Add( Props{ File: output, Compression: 6, Password: "mYSuppaPAssWORD", Threads: 4, Delete: true, }, input) fmt.Printf("p7zip output: %s\n", out) fmt.Printf("Error: %v\n", err)
Output:
func AddList ¶
AddList adds files to archive from slice
Example ¶
input1 := "log1.txt" input2 := "log2.txt" input3 := "log3.txt" output := "log.7z" out, err := AddList(Props{File: output}, []string{input1, input2, input3}) fmt.Printf("p7zip output: %s\n", out) fmt.Printf("error: %v\n", err)
Output:
func Check ¶
Check tests archive
Example ¶
ok, err := Check(Props{File: "log.7z"}) fmt.Printf("File ok: %t\n", ok) fmt.Printf("Error: %v\n", err)
Output:
Types ¶
type FileInfo ¶
type FileInfo struct { Modified time.Time Created time.Time Accessed time.Time Method []string Path string Folder string Attributes string Comment string HostOS string Size int PackedSize int CRC int Block int Version int Encrypted bool }
FileInfo contains info about file inside archive
type Info ¶
type Info struct { Method []string Files []*FileInfo Path string Type string Blocks int PhysicalSize int HeadersSize int Solid bool }
Info contains info about archive
func List ¶
List returns info about archive
Example ¶
info, err := List(Props{File: "log.7z"}) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Path: %s\n", info.Path) fmt.Printf("Type: %s\n", info.Type) fmt.Printf("Solid: %t\n", info.Solid) fmt.Printf("Blocks: %d\n", info.Blocks) fmt.Printf("PhysicalSize: %d\n", info.PhysicalSize) fmt.Printf("HeadersSize: %d\n", info.HeadersSize) fmt.Println("Files:") for _, file := range info.Files { fmt.Printf(" %s (size: %d)\n", file.Path, file.Size) }
Output:
type Props ¶
type Props struct { Dir string // Directory with files (for relative paths) File string // Output file name IncludeFile string // File with include filenames Exclude string // Exclude filenames ExcludeFile string // File with exclude filenames OutputDir string // Output dir (for extract command) Password string // Password WorkingDir string // Working dir Compression int // Compression level (0-9) Threads int // Number of CPU threads Recursive bool // Recurse subdirectories Delete bool // Delete files after compression }
Props contains properties for packing/unpacking data
Click to show internal directories.
Click to hide internal directories.