Created os_win.v and added `get_file_handle`

pull/899/head
0x9ef 2019-07-01 18:45:55 +03:00 committed by Alexander Medvednikov
parent 95841a31d4
commit 1ca20196d0
1 changed files with 15 additions and 0 deletions

15
vlib/os/os_win.v 100644
View File

@ -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
}