From 51f780e6376c55e06744ba121da03ba2200c7a71 Mon Sep 17 00:00:00 2001 From: ValKmjolnir Date: Sat, 16 Jul 2022 17:47:43 +0800 Subject: [PATCH] :bug: fix error use of FindFirstFile. --- nasal_builtin.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nasal_builtin.h b/nasal_builtin.h index e00a184..fbf81cf 100644 --- a/nasal_builtin.h +++ b/nasal_builtin.h @@ -768,7 +768,7 @@ nasal_ref builtin_open(nasal_ref* local,nasal_gc& gc) return builtin_err("open","\"mode\" must be string"); FILE* res=fopen(name.str().c_str(),mode.str().c_str()); if(!res) - return builtin_err("open","failed to open file <"+name.str()+"> errno "+std::to_string(errno)); + return builtin_err("open","failed to open file <"+name.str()+">"); nasal_ref ret=gc.alloc(vm_obj); ret.obj().type=nasal_obj::file; ret.obj().ptr=(void*)res; @@ -1044,13 +1044,13 @@ nasal_ref builtin_opendir(nasal_ref* local,nasal_gc& gc) #ifdef _MSC_VER WIN32_FIND_DATA data; HANDLE p; - p=FindFirstFile(path.str().c_str(),&data); + p=FindFirstFile((path.str()+"\\*.*").c_str(),&data); if(p==INVALID_HANDLE_VALUE) - return builtin_err("opendir","cannot open dir <"+path.str()+"> errno "+std::to_string(errno)); + return builtin_err("opendir","cannot open dir <"+path.str()+">"); #else DIR* p=opendir(path.str().c_str()); if(!p) - return builtin_err("opendir","cannot open dir <"+path.str()+"> errno "+std::to_string(errno)); + return builtin_err("opendir","cannot open dir <"+path.str()+">"); #endif nasal_ref ret=gc.alloc(vm_obj); ret.obj().type=nasal_obj::dir;