--- parser3/src/main/pa_dir.C 2026/04/25 13:38:46 1.34 +++ parser3/src/main/pa_dir.C 2026/10/11 17:06:44 1.41 @@ -6,11 +6,13 @@ */ #include "pa_common.h" +#include "pa_file.h" #include "pa_dir.h" +#include "pa_os.h" #include "pa_request.h" #include "pa_convert_utf.h" -volatile const char * IDENT_PA_DIR_C="$Id: pa_dir.C,v 1.34 2026/04/25 13:38:46 moko Exp $" IDENT_PA_DIR_H; +volatile const char * IDENT_PA_DIR_C="$Id: pa_dir.C,v 1.41 2026/10/11 17:06:44 moko Exp $" IDENT_PA_DIR_H; #ifdef _MSC_VER @@ -34,9 +36,13 @@ bool findfirst(const char* _pathname, st snprintf(mask, MAXPATH, "%s/*.*", _pathname); const UTF16* utf16mask=pa_utf16_encode(mask, pa_thread_request().charsets.source()); + if(!utf16mask) { // not UTF-8, there can't be such a directory + errno=ENOENT; + return false; + } _ffblk->handle=FindFirstFileW((const wchar_t *)utf16mask, &_ffblk->stat); - return _ffblk->handle==INVALID_HANDLE_VALUE; + return !pa_set_errno(_ffblk->handle!=INVALID_HANDLE_VALUE); // errno as opendir sets it } bool findnext(struct ffblk *_ffblk) {