fix dir_exists on win

pull/1168/head
Joe Conigliaro 2019-07-17 02:01:36 +10:00 committed by Alexander Medvednikov
parent 1748632144
commit 36442976c3
1 changed files with 10 additions and 7 deletions

View File

@ -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())