dsstore

package module
v0.0.0-...-054e73b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2020 License: MIT Imports: 10 Imported by: 0

README

Golang .DS_Store reader and writer

Go implemetation for reading and writing for .DS_Store files. The implemetation based on:

Looks as work. I use it for renaming application name in .DS_Store template when collecting DMG installer.

Parsed .DS_Store records contains the folowing fields:

  • FileName - file name

  • Extra - unknown 4 bytes

  • Type - 4 bytes string

  • DataLen - data len for some types (blob, ustr), for primitive types it must be 0.

    When value is zero DataLen is not writes to output. So zero-size blobs doesn't work.

  • Data - bytes arrays of data

The full description about .DS_Store records can be found here:

https://metacpan.org/pod/distribution/Mac-Finder-DSStore/DSStoreFormat.pod#Records

The implementation just reads and writes container and don't parse Data field and etc. Data field with "blob" type often contains binary property list (plist) and should be parsed through other modules or libraries.

Blocks allocation on writing can be have different order and size than be was read.

WARNING

BE CAREFUL USE IT FOR WRITING .DS_Store!

Do not use it for massive modifying of .DS_Store files. Just use it for installer purpose (preparing .DS_Store for DMG).

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Record

type Record struct {
	FileName string // file name
	Extra    uint32 // extra (unknown data)
	Type     string // type
	DataLen  uint32 // explicit data size in bytes
	Data     []byte // raw data
}

Record in .DS_Store

type Store

type Store struct {
	HeaderExtra []byte   // header extra data (unknown)
	RootExtra   []byte   // root (bookkeeping) extra data (unknown)
	DSDBExtra   []byte   // DSDB extra data (unknown)
	Records     []Record // records
}

Store of .DS_Store file

func (*Store) Read

func (s *Store) Read(r io.Reader) error

Read reads .DS_Store from io.Reader

func (*Store) ReadFile

func (s *Store) ReadFile(filename string) error

ReadFile reads .DS_Store from the file

func (*Store) Write

func (s *Store) Write(w io.Writer) error

WriteStore writes .DS_Store to io.Writer

func (*Store) WriteFile

func (s *Store) WriteFile(filename string, perm os.FileMode) error

WriteFile writes .DS_Store to the file

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL