diff --git a/src/libs/portability/CMakeLists.txt b/src/libs/portability/CMakeLists.txt index 1bd90c1ea..0f652ed42 100644 --- a/src/libs/portability/CMakeLists.txt +++ b/src/libs/portability/CMakeLists.txt @@ -25,6 +25,10 @@ ENDIF(WIN32) # Note: Headers needed for having them available in IDEs. SD_ADD_LIBRARY(portability SHARED ${PORTABILITY_SOURCES} ${PORTABILITY_HEADERS}) +IF(WIN32) + TARGET_LINK_LIBRARIES(portability shlwapi) +ENDIF() + target_include_directories(portability PUBLIC ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_LIST_DIR} diff --git a/src/libs/portability/win32/rmdir_r.cpp b/src/libs/portability/win32/rmdir_r.cpp index cca9f3e21..e99a7c430 100644 --- a/src/libs/portability/win32/rmdir_r.cpp +++ b/src/libs/portability/win32/rmdir_r.cpp @@ -13,10 +13,12 @@ #include #include +#include #include #include #include #include +#include #include #include @@ -45,10 +47,15 @@ failure: int portability::rmdir_r(const char *path) { int ret = -1, res; - char *dir = getdir(path); SHFILEOPSTRUCT op = {0}; + char *dir = nullptr; - if (!dir) + if (!PathFileExistsA(path)) + { + ret = 0; + goto end; + } + else if (!(dir = getdir(path))) { fprintf(stderr, "%s: getdir failed\n", __func__); goto end;