From cf8a1122e00813a39b5ad0c58c1a84cf04bcc80c Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Sun, 1 Feb 2026 20:43:59 -0500 Subject: [PATCH] Initialize iOS dirs --- 0.go | 13 ++++++++++--- 0_ios.go | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 0_ios.go diff --git a/0.go b/0.go index 49a6fcf..342dc74 100644 --- a/0.go +++ b/0.go @@ -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 -func FreeArray(array C.PascalStringArray) { +//export FreePascalArray +func FreePascalArray(array C.PascalStringArray) { linesSlice := (*[1 << 30]C.PascalString)(unsafe.Pointer(array.data))[:array.len:array.len] for i := 0; i < int(array.len); i++ { C.free(unsafe.Pointer(linesSlice[i].data)) @@ -73,6 +73,13 @@ func FreeArray(array C.PascalStringArray) { 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. func safeStringDeref(s *string) string { if s == nil { diff --git a/0_ios.go b/0_ios.go new file mode 100644 index 0000000..ee7acf9 --- /dev/null +++ b/0_ios.go @@ -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) +}