summaryrefslogtreecommitdiff
path: root/redo/dialog_windows.go
diff options
context:
space:
mode:
Diffstat (limited to 'redo/dialog_windows.go')
-rw-r--r--redo/dialog_windows.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/redo/dialog_windows.go b/redo/dialog_windows.go
new file mode 100644
index 0000000..0346f56
--- /dev/null
+++ b/redo/dialog_windows.go
@@ -0,0 +1,33 @@
+// 18 august 2014
+
+package ui
+
+import (
+ "syscall"
+ "unsafe"
+ "reflect"
+)
+
+// #include "winapi_windows.h"
+import "C"
+
+// TODO move to common_windows.go
+func wstrToString(wstr *C.WCHAR) string {
+ n := C.wcslen((*C.wchar_t)(unsafe.Pointer(wstr)))
+ xbuf := &reflect.SliceHeader{
+ Data: uintptr(unsafe.Pointer(wstr)),
+ Len: int(n + 1),
+ Cap: int(n + 1),
+ }
+ buf := (*[]uint16)(unsafe.Pointer(xbuf))
+ return syscall.UTF16ToString(*buf)
+}
+
+func openFile() string {
+ name := C.openFile()
+ if name == nil {
+ return ""
+ }
+ defer C.free(unsafe.Pointer(name))
+ return wstrToString(name)
+}