mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-12-04 05:43:27 +01:00
Bare dir now always means a user data dir, so the snapshot root, the export listing, and the keys.json kind get their own words; names used only inside their package are no longer exported.
32 lines
653 B
Go
32 lines
653 B
Go
package snapshot
|
|
|
|
import (
|
|
"fmt"
|
|
"io/fs"
|
|
"path/filepath"
|
|
|
|
"github.com/moond4rk/hackbrowserdata/internal/zipfile"
|
|
)
|
|
|
|
func (r *Root) Zip(archivePath string) error {
|
|
var names []string
|
|
walkErr := filepath.WalkDir(r.path, func(walkedPath string, entry fs.DirEntry, err error) error {
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if entry.IsDir() {
|
|
return nil
|
|
}
|
|
relativePath, err := filepath.Rel(r.path, walkedPath)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
names = append(names, filepath.ToSlash(relativePath))
|
|
return nil
|
|
})
|
|
if walkErr != nil {
|
|
return fmt.Errorf("zip %s: %w", r.path, walkErr)
|
|
}
|
|
return zipfile.Write(archivePath, r.path, names)
|
|
}
|