2025-11-02 12:23:25 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"io/fs"
|
|
|
|
|
"os"
|
|
|
|
|
|
2025-11-02 13:27:04 +00:00
|
|
|
"github.com/Snider/Borg/pkg/compress"
|
2025-11-02 12:23:25 +00:00
|
|
|
"github.com/Snider/Borg/pkg/datanode"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
if len(os.Args) != 2 {
|
|
|
|
|
fmt.Println("Usage: go run inspect_datanode.go <path to .dat file>")
|
|
|
|
|
os.Exit(1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
datFile := os.Args[1]
|
|
|
|
|
|
2025-11-02 13:27:04 +00:00
|
|
|
rawData, err := os.ReadFile(datFile)
|
2025-11-02 12:23:25 +00:00
|
|
|
if err != nil {
|
|
|
|
|
fmt.Printf("Error reading .dat file: %v\n", err)
|
|
|
|
|
os.Exit(1)
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-02 13:27:04 +00:00
|
|
|
data, err := compress.Decompress(rawData)
|
|
|
|
|
if err != nil {
|
|
|
|
|
fmt.Printf("Error decompressing data: %v\n", err)
|
|
|
|
|
os.Exit(1)
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-02 12:23:25 +00:00
|
|
|
dn, err := datanode.FromTar(data)
|
|
|
|
|
if err != nil {
|
|
|
|
|
fmt.Printf("Error creating DataNode from tarball: %v\n", err)
|
|
|
|
|
os.Exit(1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fmt.Printf("Contents of %s:\n", datFile)
|
|
|
|
|
err = dn.Walk(".", func(path string, d fs.DirEntry, err error) error {
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
fmt.Println(path)
|
|
|
|
|
return nil
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
fmt.Printf("Error walking DataNode: %v\n", err)
|
|
|
|
|
os.Exit(1)
|
|
|
|
|
}
|
|
|
|
|
}
|