From 1ca20196d0ed6375b8ed95781e5b0a84b2cd33c8 Mon Sep 17 00:00:00 2001 From: 0x9ef <43169346+0x9ef@users.noreply.github.com> Date: Mon, 1 Jul 2019 18:45:55 +0300 Subject: [PATCH] Created os_win.v and added `get_file_handle` --- vlib/os/os_win.v | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 vlib/os/os_win.v diff --git a/vlib/os/os_win.v b/vlib/os/os_win.v new file mode 100644 index 0000000000..586f3eb807 --- /dev/null +++ b/vlib/os/os_win.v @@ -0,0 +1,15 @@ +module os + +// Ref - https://docs.microsoft.com/en-us/windows/desktop/winprog/windows-data-types +// A handle to an object. +type HANDLE voidptr // C.HANDLE + +pub fn get_file_handle(path string) HANDLE { + mode := 'r' + _fh := C.fopen(path.cstr(), mode.cstr()) + if isnil(_fh) { + return HANDLE(INVALID_HANDLE_VALUE) + } + _handle := C._get_osfhandle(C._fileno(_fh)) // CreateFile? - hah, no -_- + return _handle +}