GO - Minimal parser for .DS_Store files
Clone or download
Latest commit 89310ce Apr 10, 2016
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE.md Added README & LICENSE Apr 6, 2016
README.md Added README & LICENSE Apr 6, 2016
ds_store.go Bugfix Apr 10, 2016

README.md

Go .DS_Store parser

This is a quick and dirty Go parser for .DS_Store files. I focused on the extraction of file names and ignored other parameters.

It does not support the full set of structure formats, so it might break in some scenarios.

#Useful information: The following descriptions and sourcecodes were quite helpful:

#Example code

package main

import (
	"fmt"
	"os"
	"flag"
	"github.com/gehaxelt/ds_store"
	"io/ioutil"
)

func main() {

	var fileName string

	flag.StringVar(&fileName, "i", "", "DS_Store input file")
	flag.Parse()

	if fileName == "" {
		panic("FileName (-i): Must be specified")
	} else if _, err := os.Stat(fileName); os.IsNotExist(err) {
		panic("FileName (-i): File does not exist:" + fileName)
	}

	dat, err := ioutil.ReadFile(fileName)

	if err != nil {
		panic(err)
	}

	a, err := ds_store.NewAllocator(dat)

	filenames, err := a.TraverseFromRootNode()
	if err != nil {
		panic(err)
	}

	for _,f := range filenames {
		fmt.Printf("File: %s \n", f)
	}
}
./ds_storeviewer -i samples/DS_Store-2
File: joomlatools-files 
File: joomlatools-files 
File: joomlatools-files 
File: joomlatools-files 

License

See License.md