mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
01d5f4d744
it is preferable to open the file in binary mode.
16 lines
429 B
Go
16 lines
429 B
Go
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 := 'rb'
|
|
_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
|
|
}
|