mirror of
https://github.com/rwinkhart/cmutton.git
synced 2026-08-27 20:36:31 -04:00
Initialize iOS dirs
This commit is contained in:
@@ -62,10 +62,10 @@ func GetPascalStringFromCString(cString *C.char) C.PascalString {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FreeArray frees the memory allocated by a C-allocated array.
|
// FreePascalArray frees the memory allocated by a C-allocated array.
|
||||||
//
|
//
|
||||||
//export FreeArray
|
//export FreePascalArray
|
||||||
func FreeArray(array C.PascalStringArray) {
|
func FreePascalArray(array C.PascalStringArray) {
|
||||||
linesSlice := (*[1 << 30]C.PascalString)(unsafe.Pointer(array.data))[:array.len:array.len]
|
linesSlice := (*[1 << 30]C.PascalString)(unsafe.Pointer(array.data))[:array.len:array.len]
|
||||||
for i := 0; i < int(array.len); i++ {
|
for i := 0; i < int(array.len); i++ {
|
||||||
C.free(unsafe.Pointer(linesSlice[i].data))
|
C.free(unsafe.Pointer(linesSlice[i].data))
|
||||||
@@ -73,6 +73,13 @@ func FreeArray(array C.PascalStringArray) {
|
|||||||
C.free(unsafe.Pointer(array.data))
|
C.free(unsafe.Pointer(array.data))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FreePascalString frees the memory allocated by a C-allocated pascal string.
|
||||||
|
//
|
||||||
|
//export FreePascalString
|
||||||
|
func FreePascalString(pascalString C.PascalString) {
|
||||||
|
C.free(unsafe.Pointer(pascalString.data))
|
||||||
|
}
|
||||||
|
|
||||||
// safeStringDeref safely dereferences a string pointer, returning empty string if nil.
|
// safeStringDeref safely dereferences a string pointer, returning empty string if nil.
|
||||||
func safeStringDeref(s *string) string {
|
func safeStringDeref(s *string) string {
|
||||||
if s == nil {
|
if s == nil {
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "C"
|
||||||
|
import (
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/rwinkhart/go-boilerplate/back"
|
||||||
|
"github.com/rwinkhart/libmutton/global"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// get the app's Library/Application Support directory (private, not backed up by iCloud)
|
||||||
|
back.Home = filepath.Join(back.Home, "Library", "Application Support", "Passture")
|
||||||
|
|
||||||
|
// change path variables to account for iOS app sandbox
|
||||||
|
global.EntryRoot = back.Home + "/entries" // Path to libmutton entry directory
|
||||||
|
global.CfgDir = back.Home + "/config" // Path to libmutton configuration directory
|
||||||
|
global.CfgPath = global.CfgDir + "/libmuttoncfg.json" // Path to libmutton configuration file
|
||||||
|
global.AgeDir = global.CfgDir + "/age" // Path to libmutton password age directory
|
||||||
|
global.RootLength = len(global.EntryRoot)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user