Documentation ¶
Overview ¶
Package zipcmt is a viewer and an extractor of zip archive comments.
Index ¶
- Variables
- func Read(name string, raw bool) (string, error)
- type Config
- func (c *Config) Clean() error
- func (c *Config) Error(err error)
- func (i *Config) LogName() string
- func (c *Config) Separator(name string) string
- func (i *Config) SetLog()
- func (i *Config) SetTest()
- func (i *Config) SetTimer()
- func (c Config) Status() string
- func (i *Config) Timer() time.Duration
- func (c *Config) WalkDir(root string) error
- func (c *Config) WalkDirs()
- func (c *Config) WriteLog(s string)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrIsFile = errors.New("directory is a file") ErrMissing = errors.New("directory cannot be found") ErrPath = errors.New("directory path cannot be found or points to a file") ErrPerm = errors.New("directory access is blocked due to its permissions") ErrValid = errors.New("the operating system reports this directory is invalid") )
Functions ¶
func Read ¶
Read the named zip file and return the zip comment. The Raw config will return the comment in its original legacy encoding. Otherwise the comment is returned as Unicode text.
Example ¶
package main import ( "fmt" "log" zipcmt "github.com/bengarrett/zipcmt/pkg" ) func main() { s, err := zipcmt.Read("../test/test-with-comment.zip", false) if err != nil { log.Fatalln(err) } fmt.Print(s) }
Output: This is an example test comment for zipcmmt.
Types ¶
type Config ¶
type Config struct { Dirs []string SaveName string Dupes bool Export bool Log bool Overwrite bool Now bool NoWalk bool Raw bool Print bool Quiet bool Zips int Cmmts int // contains filtered or unexported fields }
func (*Config) Clean ¶
Clean the syntax of the target export directory path.
Example ¶
package main import ( "fmt" "log" zipcmt "github.com/bengarrett/zipcmt/pkg" ) func main() { c := zipcmt.Config{ SaveName: "..//test///.", } if err := c.Clean(); err != nil { log.Fatalln(err) } fmt.Print(c.SaveName) }
Output: ../test
func (*Config) LogName ¶
func (i *Config) LogName() string
SetLog returns the full path to the log file.
func (*Config) SetLog ¶
func (i *Config) SetLog()
SetLog sets the full path to a new log file with a name based on the current date and time.
func (*Config) SetTimer ¶
func (i *Config) SetTimer()
SetTimer initializes a timer for process time.
func (Config) Status ¶
Status summarizes the zip files scan.
Example ¶
package main import ( "fmt" "log" zipcmt "github.com/bengarrett/zipcmt/pkg" ) func main() { c := zipcmt.Config{} c.SetTest() if err := c.WalkDir("../test"); err != nil { log.Panicln(err) } fmt.Print(c.Status()) c = zipcmt.Config{ Dupes: true, } c.SetTest() if err := c.WalkDir("../test"); err != nil { log.Panicln(err) } fmt.Print(c.Status()) }
Output: Scanned 4 zip archives and found 1 unique comment Scanned 4 zip archives and found 2 comments
func (*Config) WalkDir ¶
WalkDir walks the root directory for zip archives and to extract any found comments.
Example ¶
package main import ( "log" zipcmt "github.com/bengarrett/zipcmt/pkg" ) func main() { c := zipcmt.Config{ Print: true, Dupes: true, } if err := c.WalkDir("../test"); err != nil { log.Panicln(err) } }
Output: ── ../test/subdir/test-with-comment.zip ─┐ This is an example test comment for zipcmmt.�[0m ── ../test/test-with-comment.zip ────────┐ This is an example test comment for zipcmmt.�[0m
Click to show internal directories.
Click to hide internal directories.