From 62f6ddef537e0b277d657ec7147b3f571f9187a2 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Thu, 10 Jul 2025 17:15:59 +0900 Subject: [PATCH 1/5] win32: dirent: Avoid to use PathIsDirectoryA This API is not existing in Windows Nano Server. Signed-off-by: Hiroshi Hatake --- src/win32/dirent.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/win32/dirent.c b/src/win32/dirent.c index 6ea57f9..75f0c5e 100644 --- a/src/win32/dirent.c +++ b/src/win32/dirent.c @@ -75,11 +75,30 @@ static char *create_pattern(const char *path) return buf; } +/** + * @brief Checks if a given path string refers to an existing directory. + * @param pszPath The null-terminated string that contains the path. + * @return Returns TRUE if the path is a directory, otherwise FALSE. + */ +BOOL path_is_directory(LPCSTR pszPath) { + DWORD dwAttrib = GetFileAttributesA(pszPath); + + if (dwAttrib == INVALID_FILE_ATTRIBUTES) { + return FALSE; + } + + if (dwAttrib & FILE_ATTRIBUTE_DIRECTORY) { + return TRUE; + } + + return FALSE; +} + struct CIO_WIN32_DIR *cio_win32_opendir(const char *path) { struct CIO_WIN32_DIR *d; - if (!PathIsDirectoryA(path)) { + if (!path_is_directory(path)) { return NULL; } From c6f2777f0677fe14d567af0c90bf427e69d23ac8 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Thu, 10 Jul 2025 17:19:43 +0900 Subject: [PATCH 2/5] build: dirent: Remove shlwapi.dll dependency for PathIsDirectoryA API Signed-off-by: Hiroshi Hatake --- src/CMakeLists.txt | 3 +-- src/win32/dirent.c | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bb52273..3590143 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -23,8 +23,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") ) set(libs ${libs} - Shell32.lib - Shlwapi.lib) + Shell32.lib) else() set(src ${src} diff --git a/src/win32/dirent.c b/src/win32/dirent.c index 75f0c5e..020943d 100644 --- a/src/win32/dirent.c +++ b/src/win32/dirent.c @@ -23,7 +23,6 @@ */ #include -#include #include "dirent.h" From 6048362f57428a87c59dda4b09cf9ed8f65f08c2 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Thu, 10 Jul 2025 19:08:04 +0900 Subject: [PATCH 3/5] workflows: Use windows-2025 instead of deprecated 2019 Signed-off-by: Hiroshi Hatake --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c937a2c..ed380cd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,7 +15,7 @@ jobs: max-parallel: 48 fail-fast: false matrix: - os: [windows-latest, windows-2019] + os: [windows-2025, windows-2022] steps: - uses: actions/checkout@v2 - name: Build on ${{ matrix.os }} with vs-2019 From f10a6eb86473c6318efdff16c4c5ae1c8bb4d1fe Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Thu, 10 Jul 2025 19:15:00 +0900 Subject: [PATCH 4/5] workflows: Run Windows unit testing correctly Signed-off-by: Hiroshi Hatake --- .github/workflows/ci.yaml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ed380cd..a816202 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,12 +18,17 @@ jobs: os: [windows-2025, windows-2022] steps: - uses: actions/checkout@v2 - - name: Build on ${{ matrix.os }} with vs-2019 + - name: Set up with Developer Command Prompt for Microsoft Visual C++ + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: amd64 + - name: Build on ${{ matrix.os }} with MSVC run: | - .\scripts\win_build.bat + cmake -G "NMake Makefiles" -DCIO_TESTS=On . + cmake --build . - name: Run unit tests. run: | - ctest --rerun-failed --output-on-failure -C Debug --test-dir . + ctest . --rerun-failed --output-on-failure --test-dir . build-unix: name: Build sources on amd64 for ${{ matrix.os }} - ${{ matrix.compiler }} runs-on: ${{ matrix.os }} From 81d6272a504300671a0cc58c1a350d57e75f66a1 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Fri, 11 Jul 2025 18:35:27 +0900 Subject: [PATCH 5/5] os: Remove SHCreateDirectoryEx dependency Signed-off-by: Hiroshi Hatake --- src/cio_os.c | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/src/cio_os.c b/src/cio_os.c index 0adbc61..c4e6c89 100644 --- a/src/cio_os.c +++ b/src/cio_os.c @@ -49,6 +49,45 @@ int cio_os_isdir(const char *dir) return -1; } +#ifdef _WIN32 +inline int cio_os_win32_make_recursive_path(const char* path) { + char dir[MAX_PATH]; + char* p = NULL; + + if (_fullpath(dir, path, MAX_PATH) == NULL) { + return 1; + } + + for (p = dir; *p; p++) { + /* Skip the drive letter (e.g., "C:") */ + if (p > dir && *p == ':' && *(p - 1) != '\0') { + continue; + } + + if (*p == '\\' || *p == '/') { + char original_char = *p; + *p = '\0'; + + if (!CreateDirectoryA(dir, NULL)) { + if (GetLastError() != ERROR_ALREADY_EXISTS) { + *p = original_char; + return 1; + } + } + *p = original_char; + } + } + + if (!CreateDirectoryA(dir, NULL)) { + if (GetLastError() != ERROR_ALREADY_EXISTS) { + return 1; + } + } + + return 0; +} +#endif + /* Create directory */ int cio_os_mkpath(const char *dir, mode_t mode) { @@ -85,7 +124,7 @@ int cio_os_mkpath(const char *dir, mode_t mode) return 1; } - if (SHCreateDirectoryExA(NULL, path, NULL) != ERROR_SUCCESS) { + if (cio_os_win32_make_recursive_path(path) != ERROR_SUCCESS) { return 1; } return 0;