func New(fn string, hashWidth, ptrBytes int) (s *Store, err error) {
	s = &Store{
		HashWidth: min(max(hashWidth, 8), 29),
		PtrBytes:  min(max(ptrBytes, 4), 7),
	}

	defer func() {
		if e := recover(); e != nil {
			s = nil
			err = e.(error)
		}
	}()

	if s.accessor, err = storage.NewFile(fn, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0666); err != nil {
		return nil, fmt.Errorf("%s: %s", me(), err)
	}

	b := []byte{
		'Z', 'O', 'N', 'E', 'D', 'B',
		byte(s.HashWidth),
		byte(s.PtrBytes),
		0, 0, 0, 0, 0, 0, 0, 0,
	}
	if n, err := s.accessor.WriteAt(b, 0); n != len(b) || err != nil {
		return nil, fmt.Errorf("%s: %s", me(), err)
	}

	if s.Store, err = hdb.New(&hdbAccessor{s.delta(), s.accessor}); err != nil {
		return nil, fmt.Errorf("%s: %s", me(), err)
	}

	return
}
// New creates the Store in named file fn, truncating it if it already exists.
// The hashWidth and ptrBytes arguments: see the Store type docs.  If
// successful, methods on the returned Store can be used for I/O. It returns
// the Store and an error, if any.
New creates the Store in named file fn, truncating it if it already exists.
The hashWidth and ptrBytes arguments: see the Store type docs.  If
successful, methods on the returned Store can be used for I/O. It returns
the Store and an error, if any.
// New creates the Store in named file fn truncating it if it already exists . // The hashWidth and ptrBytes arguments : see the Store type docs . If // successful methods on the returned Store can be used for I / O . It returns // the Store and an error if any .
func New(fn string, hashWidth, ptrBytes int) (s *Store, err error) {
	s = &Store{
		HashWidth: min(max(hashWidth, 8), 29),
		PtrBytes:  min(max(ptrBytes, 4), 7),
	}
	defer func() {
		if e := recover(); e != nil {
			s = nil
			err = e.(error)
		}
	}()
	if s.accessor, err = storage.NewFile(fn, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0666); err != nil {
		return nil, fmt.Errorf("%s: %s", me(), err)
	}
	b := []byte{
		'Z', 'O', 'N', 'E', 'D', 'B',
		byte(s.HashWidth),
		byte(s.PtrBytes),
		0, 0, 0, 0, 0, 0, 0, 0,
	}
	if n, err := s.accessor.WriteAt(b, 0); n != len(b) || err != nil {
		return nil, fmt.Errorf("%s: %s", me(), err)
	}
	if s.Store, err = hdb.New(&hdbAccessor{s.delta(), s.accessor}); err != nil {
		return nil, fmt.Errorf("%s: %s", me(), err)
	}
	return
}
func New ( fn string , hashWidth , ptrBytes int ) ( s * Store , err error ) { s = & Store { HashWidth : min ( max ( hashWidth , 8 ) , 29 ) , PtrBytes : min ( max ( ptrBytes , 4 ) , 7 ) , } defer func ( ) { if e := recover ( ) ; e != nil { s = nil err = e . ( error ) } } ( ) if s . accessor , err = storage . NewFile ( fn , os . O_CREATE | os . O_RDWR | os . O_TRUNC , 0666 ) ; err != nil { return nil , fmt . Errorf ( " " , me ( ) , err ) } b := [ ] byte { 'Z' , 'O' , 'N' , 'E' , 'D' , 'B' , byte ( s . HashWidth ) , byte ( s . PtrBytes ) , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , } if n , err := s . accessor . WriteAt ( b , 0 ) ; n != len ( b ) || err != nil { return nil , fmt . Errorf ( " " , me ( ) , err ) } if s . Store , err = hdb . New ( & hdbAccessor { s . delta ( ) , s . accessor } ) ; err != nil { return nil , fmt . Errorf ( " " , me ( ) , err ) } return }
New creates the Store in named file fn, truncating it if it already exists.
New creates the Store in named file fn truncating it if it already exists .