Ejemplo n.º 1
0
Archivo: db.go Proyecto: gmuch/gmuch
// Create creates a new, empty notmuch database located at 'path'.
func Create(path string) (*DB, error) {
	cpath := C.CString(path)
	defer C.free(unsafe.Pointer(cpath))
	var cdb *C.notmuch_database_t
	err := statusErr(C.notmuch_database_create(cpath, &cdb))
	if err != nil {
		return nil, err
	}
	db := &DB{cptr: unsafe.Pointer(cdb)}
	setGcClose(db)
	return db, nil
}
Ejemplo n.º 2
0
// Create a new, empty notmuch database located at 'path'
func NewDatabase(path string) (*Database, Status) {

	var c_path *C.char = C.CString(path)
	defer C.free(unsafe.Pointer(c_path))

	if c_path == nil {
		return nil, STATUS_OUT_OF_MEMORY
	}

	self := &Database{db: nil}
	st := Status(C.notmuch_database_create(c_path, &self.db))
	if st != STATUS_SUCCESS {
		return nil, st
	}
	return self, st
}