always open databases read/write
This commit is contained in:
parent
d2ec12798e
commit
9fb5bdad78
31
main.go
31
main.go
@ -24,36 +24,9 @@ func GetMagic() int64 {
|
||||
return Magic
|
||||
}
|
||||
|
||||
//export Bolt_Options_New
|
||||
func Bolt_Options_New() ObjectReference {
|
||||
b := *bolt.DefaultOptions
|
||||
|
||||
return gms.Put(&b)
|
||||
}
|
||||
|
||||
//export Bolt_Options_New_Readonly
|
||||
func Bolt_Options_New_Readonly() ObjectReference {
|
||||
b := *bolt.DefaultOptions
|
||||
b.ReadOnly = true
|
||||
|
||||
return gms.Put(&b)
|
||||
}
|
||||
|
||||
//export Bolt_Open
|
||||
func Bolt_Open(path string, mode uint32, opts ObjectReference) (ObjectReference, *C.char, int) {
|
||||
optsIFC, ok := gms.Get(opts)
|
||||
if !ok {
|
||||
errMsg := NullObjectReference.Error()
|
||||
return 0, C.CString(errMsg), len(errMsg)
|
||||
}
|
||||
|
||||
ptrBoltOps, ok := optsIFC.(*bolt.Options)
|
||||
if !ok {
|
||||
errMsg := NullObjectReference.Error()
|
||||
return 0, C.CString(errMsg), len(errMsg)
|
||||
}
|
||||
|
||||
ptrDB, err := bolt.Open(path, os.FileMode(mode), ptrBoltOps)
|
||||
func Bolt_Open(path string) (ObjectReference, *C.char, int) {
|
||||
ptrDB, err := bolt.Open(path, os.FileMode(0644), bolt.DefaultOptions)
|
||||
if err != nil {
|
||||
errMsg := err.Error()
|
||||
return 0, C.CString(errMsg), len(errMsg)
|
||||
|
@ -9,12 +9,10 @@ BoltDB::BoltDB()
|
||||
|
||||
BoltDB* BoltDB::createFrom(QString filePath, QString &errorOut)
|
||||
{
|
||||
auto opts = ::Bolt_Options_New_Readonly();
|
||||
|
||||
QByteArray filePathBytes(filePath.toUtf8());
|
||||
GoString filePathGS = Interop::toGoString_WeakRef(&filePathBytes);
|
||||
|
||||
auto open_ret = ::Bolt_Open(filePathGS, 0444, opts);
|
||||
auto open_ret = ::Bolt_Open(filePathGS);
|
||||
if (open_ret.r2 != 0) {
|
||||
errorOut = QString::fromUtf8(open_ret.r1, open_ret.r2);
|
||||
free(open_ret.r1);
|
||||
|
Loading…
Reference in New Issue
Block a user