diff --git a/src/io/file_manager.cpp b/src/io/file_manager.cpp index df87df5e13..336ba7ccfb 100644 --- a/src/io/file_manager.cpp +++ b/src/io/file_manager.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #include @@ -60,7 +61,7 @@ namespace irr { } // For mkdir -#if !defined(WIN32) +#if !defined(WIN_BUILD) # include # include # include @@ -1245,7 +1246,7 @@ void FileManager::checkAndCreateGPDir() } // checkAndCreateGPDir // ---------------------------------------------------------------------------- -#if !defined(WIN32) && !defined(__APPLE__) +#if !defined(WIN_BUILD) && !defined(__APPLE__) /** Find a directory to use for remaining unix variants. Use the new standards * for config directory based on XDG_* environment variables, or a @@ -1532,7 +1533,7 @@ bool FileManager::removeFile(const std::string &name) const if(FileUtils::statU8Path(name, &mystat) < 0) return false; if( S_ISREG(mystat.st_mode)) { -#if defined(WIN32) +#if defined(WIN_BUILD) return _wremove(StringUtils::utf8ToWide(name).c_str()) == 0; #else return remove(name.c_str()) == 0; @@ -1584,7 +1585,7 @@ bool FileManager::removeDirectory(const std::string &name) const } } -#if defined(WIN32) +#if defined(WIN_BUILD) return RemoveDirectory(StringUtils::utf8ToWide(name).c_str())==TRUE; #else return remove(name.c_str())==0; @@ -1659,10 +1660,16 @@ bool FileManager::moveDirectoryInto(std::string source, std::string target) if (isDirectory(target)) return false; -#if defined(WIN32) - return MoveFileExW(StringUtils::utf8ToWide(source).c_str(), - StringUtils::utf8ToWide(target).c_str(), - MOVEFILE_WRITE_THROUGH) != 0; +#if defined(WIN_BUILD) + try{ + std::filesystem::copy(source.c_str(), target.c_str(), std::filesystem::copy_options::recursive); + std::filesystem::remove_all(source.c_str()); + return 1; + } + catch(std::filesystem::filesystem_error const& ex){ + Log::error("FileManager", "%s", ex.what()); + return 0; + } #else return rename(source.c_str(), target.c_str()) != -1; #endif