From 6fcfbd9bdb52d662e9828fd84e7890ccc6a52549 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 25 Aug 2014 16:20:10 -0400 Subject: [PATCH] Moved some functions around. --- redo/common_windows.go | 11 +++++++++++ redo/dialog_windows.go | 12 ------------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/redo/common_windows.go b/redo/common_windows.go index 3ec4ddd..65eb781 100644 --- a/redo/common_windows.go +++ b/redo/common_windows.go @@ -44,3 +44,14 @@ func getWindowText(hwnd C.HWND) string { C.LPWSTR(unsafe.Pointer(&buf[0]))) return syscall.UTF16ToString(buf) } + +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) +} diff --git a/redo/dialog_windows.go b/redo/dialog_windows.go index 0346f56..1ca7771 100644 --- a/redo/dialog_windows.go +++ b/redo/dialog_windows.go @@ -11,18 +11,6 @@ import ( // #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 {