Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions src/io/file_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include <sys/stat.h>
#include <iostream>
#include <string>
#include <filesystem>

#include <IFileSystem.h>

Expand All @@ -60,7 +61,7 @@ namespace irr {
}

// For mkdir
#if !defined(WIN32)
#if !defined(WIN_BUILD)
# include <sys/stat.h>
# include <sys/types.h>
# include <dirent.h>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Loading