1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

fix dir_exists on win

This commit is contained in:
Joe Conigliaro 2019-07-17 02:01:36 +10:00 committed by Alexander Medvednikov
parent 1748632144
commit 36442976c3

View File

@ -29,11 +29,9 @@ const (
MAX_PATH = 4096 MAX_PATH = 4096
) )
const ( // Windows
FILE_ATTRIBUTE_DIRECTORY = 16 // Windows
)
import const ( import const (
FILE_ATTRIBUTE_DIRECTORY
INVALID_FILE_ATTRIBUTES INVALID_FILE_ATTRIBUTES
) )
@ -327,9 +325,14 @@ pub fn file_exists(path string) bool {
pub fn dir_exists(path string) bool { pub fn dir_exists(path string) bool {
$if windows { $if windows {
return file_exists(path) attr := int(C.GetFileAttributes(path.cstr()))
//attr := int(C.GetFileAttributes(path.cstr())) if attr == INVALID_FILE_ATTRIBUTES {
//return attr & FILE_ATTRIBUTE_DIRECTORY return false
}
if (attr & FILE_ATTRIBUTE_DIRECTORY) != 0 {
return true
}
return false
} }
$else { $else {
dir := C.opendir(path.cstr()) dir := C.opendir(path.cstr())