--- parser3/src/main/pa_dir.C 2026/09/18 20:08:37 1.35 +++ parser3/src/main/pa_dir.C 2026/10/11 17:06:44 1.41 @@ -6,23 +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.35 2026/09/18 20:08:37 moko Exp $" IDENT_PA_DIR_H; - -#ifdef WIN32 -bool is_os_absolute_path(const String& path) { - return is_os_absolute_path(path.cstr()); -} - -bool is_os_absolute_path(const char* path) { - return path[0] && path[0]!=':' && path[1]==':' // DRIVE: (including drive-relative paths, for compatibility) - || path[0]=='\\' && path[1]=='\\' // UNC - || path[0]=='/' && path[1]=='/'; -} -#endif +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 @@ -46,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) {