From 36442976c32b4eb5a46d233b9afe05c71f9d2ba1 Mon Sep 17 00:00:00 2001 From: Joe Conigliaro Date: Wed, 17 Jul 2019 02:01:36 +1000 Subject: [PATCH] fix dir_exists on win --- vlib/os/os.v | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/vlib/os/os.v b/vlib/os/os.v index 87adc2b109..507a444e78 100644 --- a/vlib/os/os.v +++ b/vlib/os/os.v @@ -29,11 +29,9 @@ const ( MAX_PATH = 4096 ) -const ( - FILE_ATTRIBUTE_DIRECTORY = 16 // Windows -) - +// Windows import const ( + FILE_ATTRIBUTE_DIRECTORY INVALID_FILE_ATTRIBUTES ) @@ -327,9 +325,14 @@ pub fn file_exists(path string) bool { pub fn dir_exists(path string) bool { $if windows { - return file_exists(path) - //attr := int(C.GetFileAttributes(path.cstr())) - //return attr & FILE_ATTRIBUTE_DIRECTORY + attr := int(C.GetFileAttributes(path.cstr())) + if attr == INVALID_FILE_ATTRIBUTES { + return false + } + if (attr & FILE_ATTRIBUTE_DIRECTORY) != 0 { + return true + } + return false } $else { dir := C.opendir(path.cstr())