diff --git a/.travis.yml b/.travis.yml index 6c47b4b2..c1bf3843 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,11 +28,10 @@ matrix: # - os: osx # compiler: clang # env: NAME="Apple macOS" NAME_SUFFIX="mac" - # osx_image: xcode10.1 + # osx_image: xcode11 # install: # - brew update # - /usr/bin/yes | pip2 uninstall numpy # see https://github.com/travis-ci/travis-ci/issues/6688 - # - brew upgrade python # - brew upgrade # - brew install boost cmake bullet ffmpeg glm openal-soft qt5 sdl2 jack freetype # - export PATH="/usr/local/opt/qt/bin:$PATH" diff --git a/cmake_configure.cmake b/cmake_configure.cmake index a7b683b3..08f5d87a 100644 --- a/cmake_configure.cmake +++ b/cmake_configure.cmake @@ -115,19 +115,8 @@ if(USE_CONAN) endif() endif() -if(FILESYSTEM_LIBRARY STREQUAL "CXX17") - set(CMAKE_CXX_STANDARD 17) - target_compile_definitions(rw_interface INTERFACE "RW_FS_LIBRARY=0") - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - target_link_libraries(rw_interface INTERFACE "stdc++fs") - endif() -elseif(FILESYSTEM_LIBRARY STREQUAL "CXXTS") - target_compile_definitions(rw_interface INTERFACE "RW_FS_LIBRARY=1") - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - target_link_libraries(rw_interface INTERFACE "stdc++fs") - endif() -else() - message(FATAL_ERROR "Illegal FILESYSTEM_LIBRARY option. (was '${FILESYSTEM_LIBRARY}')") +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + target_link_libraries(rw_interface INTERFACE "stdc++fs") endif() if(ENABLE_SCRIPT_DEBUG) diff --git a/cmake_options.cmake b/cmake_options.cmake index 7ff53ac2..4dceabbb 100644 --- a/cmake_options.cmake +++ b/cmake_options.cmake @@ -12,9 +12,6 @@ option(TEST_DATA "Enable tests that require game data") set(FAILED_CHECK_ACTION "IGNORE" CACHE STRING "What action to perform on a failed RW_CHECK (in debug mode)") set_property(CACHE FAILED_CHECK_ACTION PROPERTY STRINGS "IGNORE" "ABORT" "BREAKPOINT") -set(FILESYSTEM_LIBRARY "CXX17" CACHE STRING "Which filesystem library to use") -set_property(CACHE FILESYSTEM_LIBRARY PROPERTY STRINGS "CXX17" "CXXTS") - set(CMAKE_CONFIGURATION_TYPES "Release;Debug;RelWithDebInfo;MinSizeRel" CACHE INTERNAL "Build types supported by this project.") if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: ${CMAKE_CONFIGURATION_TYPES}") diff --git a/rwcore/CMakeLists.txt b/rwcore/CMakeLists.txt index 4effa3cb..40173da4 100644 --- a/rwcore/CMakeLists.txt +++ b/rwcore/CMakeLists.txt @@ -11,7 +11,6 @@ add_library(rwcore rw/abort.cpp rw/casts.hpp - rw/filesystem.hpp rw/forward.hpp rw/types.hpp rw/debug.hpp diff --git a/rwcore/loaders/LoaderIMG.cpp b/rwcore/loaders/LoaderIMG.cpp index 374ae13a..8d729a0b 100644 --- a/rwcore/loaders/LoaderIMG.cpp +++ b/rwcore/loaders/LoaderIMG.cpp @@ -22,7 +22,7 @@ void to_lowercase_inplace(char* name) { } -bool LoaderIMG::load(const rwfs::path& filepath) { +bool LoaderIMG::load(const std::filesystem::path& filepath) { assert(m_archive.empty()); m_archive = filepath; diff --git a/rwcore/loaders/LoaderIMG.hpp b/rwcore/loaders/LoaderIMG.hpp index 0fe11935..645299c9 100644 --- a/rwcore/loaders/LoaderIMG.hpp +++ b/rwcore/loaders/LoaderIMG.hpp @@ -2,13 +2,12 @@ #define _LIBRW_LOADERIMG_HPP_ #include +#include #include #include #include #include -#include - /// \brief Points to one file within the archive class LoaderIMGFile { public: @@ -40,7 +39,7 @@ public: /// Load the structure of the archive /// Omit the extension in filename so both .dir and .img are loaded when /// appropriate - bool load(const rwfs::path& filepath); + bool load(const std::filesystem::path& filepath); /// Load a file from the archive to memory and pass a pointer to it /// Warning: Returns nullptr if by any reason it can't load the file @@ -72,7 +71,7 @@ public: private: Version m_version = GTAIIIVC; ///< Version of this IMG archive - rwfs::path m_archive; ///< Path to the archive being used (no extension) + std::filesystem::path m_archive; ///< Path to the archive being used (no extension) std::ifstream m_archive_stream; ///< File stream for archive std::vector m_assets; ///< Asset info of the archive diff --git a/rwcore/loaders/LoaderSDT.cpp b/rwcore/loaders/LoaderSDT.cpp index 0cb42644..5ce8d1fc 100644 --- a/rwcore/loaders/LoaderSDT.cpp +++ b/rwcore/loaders/LoaderSDT.cpp @@ -6,7 +6,7 @@ #include "rw/debug.hpp" -bool LoaderSDT::load(const rwfs::path& sdtPath, const rwfs::path& rawPath) { +bool LoaderSDT::load(const std::filesystem::path& sdtPath, const std::filesystem::path& rawPath) { const auto sdtName = sdtPath.string(); const auto rawName = rawPath.string(); diff --git a/rwcore/loaders/LoaderSDT.hpp b/rwcore/loaders/LoaderSDT.hpp index d79c70e2..d4746d3d 100644 --- a/rwcore/loaders/LoaderSDT.hpp +++ b/rwcore/loaders/LoaderSDT.hpp @@ -1,10 +1,9 @@ #ifndef _LIBRW_LOADERSDT_HPP_ #define _LIBRW_LOADERSDT_HPP_ -#include - #include #include +#include #include #include #include @@ -62,7 +61,7 @@ public: ~LoaderSDT() = default; /// Load the structure of the archive - bool load(const rwfs::path& sdtPath, const rwfs::path& rawPath); + bool load(const std::filesystem::path& sdtPath, const std::filesystem::path& rawPath); /// Load a file from the archive to memory and pass a pointer to it /// Warning: Returns nullptr if by any reason it can't load the file diff --git a/rwcore/platform/FileIndex.cpp b/rwcore/platform/FileIndex.cpp index dd397f17..cd4b58c6 100644 --- a/rwcore/platform/FileIndex.cpp +++ b/rwcore/platform/FileIndex.cpp @@ -19,14 +19,14 @@ std::string FileIndex::normalizeFilePath(const std::string &filePath) { return oss.str(); } -void FileIndex::indexTree(const rwfs::path &path) { +void FileIndex::indexTree(const std::filesystem::path &path) { // Remove the trailing "/" or "/." from base_path. Boost 1.66 and c++17 have different lexically_relative behavior. - rwfs::path basePath = (path / ".").lexically_normal(); + std::filesystem::path basePath = (path / ".").lexically_normal(); basePath = basePath.parent_path(); - for (const rwfs::path &path : - rwfs::recursive_directory_iterator(basePath)) { - if (!rwfs::is_regular_file(path)) { + for (const std::filesystem::path &path : + std::filesystem::recursive_directory_iterator(basePath)) { + if (!std::filesystem::is_regular_file(path)) { continue; } auto relPath = path.lexically_relative(basePath); @@ -43,7 +43,7 @@ const FileIndex::IndexedData *FileIndex::getIndexedDataAt(const std::string &fil return &indexedData_.at(normPath); } -rwfs::path FileIndex::findFilePath(const std::string &filePath) const { +std::filesystem::path FileIndex::findFilePath(const std::string &filePath) const { return getIndexedDataAt(filePath)->path; } @@ -70,7 +70,7 @@ FileContentsInfo FileIndex::openFileRaw(const std::string &filePath) const { } void FileIndex::indexArchive(const std::string &archive) { - rwfs::path path = findFilePath(archive); + std::filesystem::path path = findFilePath(archive); LoaderIMG& img = loaders_[path.string()]; if (!img.load(path.string())) { @@ -109,7 +109,7 @@ FileContentsInfo FileIndex::openFile(const std::string &filePath) { auto& loader = loaderPos->second; LoaderIMGFile file; - auto filename = rwfs::path(indexedData.assetData).filename().string(); + auto filename = std::filesystem::path(indexedData.assetData).filename().string(); if (loader.findAssetInfo(filename, file)) { length = file.size * 2048; data = loader.loadToMemory(filename); diff --git a/rwcore/platform/FileIndex.hpp b/rwcore/platform/FileIndex.hpp index 186d9167..9cca0b22 100644 --- a/rwcore/platform/FileIndex.hpp +++ b/rwcore/platform/FileIndex.hpp @@ -1,11 +1,11 @@ #ifndef _LIBRW_FILEINDEX_HPP_ #define _LIBRW_FILEINDEX_HPP_ +#include #include #include #include -#include #include @@ -25,7 +25,7 @@ public: * This is used to build the mapping of lower-case file paths to the * true case on the file system for platforms where this is an issue. */ - void indexTree(const rwfs::path &path); + void indexTree(const std::filesystem::path &path); /** * @brief findFilePath finds disk path for a game data file @@ -33,7 +33,7 @@ public: * @return The file path as it exists on disk * @throws if this FileIndex has not indexed the path */ - rwfs::path findFilePath(const std::string &filePath) const; + std::filesystem::path findFilePath(const std::string &filePath) const; /** * @brief openFileRaw Opens a raw file on the disk diff --git a/rwcore/rw/filesystem.hpp b/rwcore/rw/filesystem.hpp deleted file mode 100644 index b0b6ff6d..00000000 --- a/rwcore/rw/filesystem.hpp +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef _LIBRW_FILESYSTEM_HPP_ -#define _LIBRW_FILESYSTEM_HPP_ - -#define RW_FS_CXX17 0 -#define RW_FS_CXXTS 1 - -#if RW_FS_LIBRARY == RW_FS_CXX17 -#include -#include -namespace rwfs { - using namespace std::filesystem; - using error_code = std::error_code; -} -#elif RW_FS_LIBRARY == RW_FS_CXXTS -#include -#include -namespace rwfs { - using namespace std::experimental::filesystem; - using error_code = std::error_code; -} -#else -#error Invalid RW_FS_LIBRARY value -#endif - -namespace std { -template <> -struct hash { - size_t operator()(const rwfs::path& p) const { - return rwfs::hash_value(p); - } -}; -} - -#endif diff --git a/rwengine/src/audio/SoundManager.hpp b/rwengine/src/audio/SoundManager.hpp index 63637796..3dc1202a 100644 --- a/rwengine/src/audio/SoundManager.hpp +++ b/rwengine/src/audio/SoundManager.hpp @@ -7,7 +7,6 @@ #include -#include #include #include diff --git a/rwengine/src/audio/SoundSource.cpp b/rwengine/src/audio/SoundSource.cpp index d2edcc2f..c93376e7 100644 --- a/rwengine/src/audio/SoundSource.cpp +++ b/rwengine/src/audio/SoundSource.cpp @@ -34,7 +34,7 @@ bool SoundSource::allocateAudioFrame() { return true; } -bool SoundSource::allocateFormatContext(const rwfs::path& filePath) { +bool SoundSource::allocateFormatContext(const std::filesystem::path& filePath) { formatContext = nullptr; if (avformat_open_input(&formatContext, filePath.string().c_str(), nullptr, nullptr) != 0) { @@ -100,7 +100,7 @@ bool SoundSource::prepareFormatContextSfx(LoaderSDT& sdt, size_t index, return true; } -bool SoundSource::findAudioStream(const rwfs::path& filePath) { +bool SoundSource::findAudioStream(const std::filesystem::path& filePath) { RW_UNUSED(filePath); // it's used by macro if (avformat_find_stream_info(formatContext, nullptr) < 0) { @@ -354,7 +354,7 @@ void SoundSource::decodeFrames(size_t framesToDecode) { } } -void SoundSource::decodeFramesWrap(const rwfs::path& filePath) { +void SoundSource::decodeFramesWrap(const std::filesystem::path& filePath) { #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 37, 100) decodeFramesLegacy(kNrFramesToPreload); #else @@ -362,7 +362,7 @@ void SoundSource::decodeFramesWrap(const rwfs::path& filePath) { #endif } -void SoundSource::decodeAndResampleFrames(const rwfs::path& filePath, +void SoundSource::decodeAndResampleFrames(const std::filesystem::path& filePath, size_t framesToDecode) { RW_UNUSED(filePath); // it's used by macro AVFrame* resampled = av_frame_alloc(); @@ -485,7 +485,7 @@ void SoundSource::exposeSfxMetadata(LoaderSDT& sdt) { sampleRate = sdt.assetInfo.sampleRate; } -void SoundSource::decodeRestSoundFramesAndCleanup(const rwfs::path& filePath) { +void SoundSource::decodeRestSoundFramesAndCleanup(const std::filesystem::path& filePath) { #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 37, 100) decodeFramesLegacy(0); #else @@ -505,7 +505,7 @@ void SoundSource::decodeRestSfxFramesAndCleanup() { cleanupAfterSfxLoading(); } -void SoundSource::loadFromFile(const rwfs::path& filePath, bool streaming) { +void SoundSource::loadFromFile(const std::filesystem::path& filePath, bool streaming) { if (allocateAudioFrame() && allocateFormatContext(filePath) && findAudioStream(filePath) && prepareCodecContextWrap()) { exposeSoundMetadata(); diff --git a/rwengine/src/audio/SoundSource.hpp b/rwengine/src/audio/SoundSource.hpp index 444e5d47..90a14345 100644 --- a/rwengine/src/audio/SoundSource.hpp +++ b/rwengine/src/audio/SoundSource.hpp @@ -1,14 +1,13 @@ #ifndef _RWENGINE_SOUND_SOURCE_HPP_ #define _RWENGINE_SOUND_SOURCE_HPP_ -#include - extern "C" { #include #include } #include +#include #include #include #include @@ -25,8 +24,6 @@ class AVStream; class AVIOContext; class LoaderSDT; -class LoaderSDT; - /// Opaque for raw sound, /// cooperate with ffmpeg /// (loading and decoding sound) @@ -38,10 +35,10 @@ class SoundSource { public: bool allocateAudioFrame(); - bool allocateFormatContext(const rwfs::path& filePath); + bool allocateFormatContext(const std::filesystem::path& filePath); bool prepareFormatContextSfx(LoaderSDT& sdt, size_t index, bool asWave); - bool findAudioStream(const rwfs::path& filePath); + bool findAudioStream(const std::filesystem::path& filePath); bool findAudioStreamSfx(); bool prepareCodecContextWrap(); @@ -59,10 +56,10 @@ public: void decodeFramesLegacy(size_t framesToDecode); #endif - void decodeFramesWrap(const rwfs::path& filePath); + void decodeFramesWrap(const std::filesystem::path& filePath); void decodeFramesSfxWrap(); void decodeFrames(size_t framesToDecode); - void decodeAndResampleFrames(const rwfs::path& filePath, + void decodeAndResampleFrames(const std::filesystem::path& filePath, size_t framesToDecode); void cleanupAfterSoundLoading(); @@ -71,11 +68,11 @@ public: void exposeSoundMetadata(); void exposeSfxMetadata(LoaderSDT& sdt); - void decodeRestSoundFramesAndCleanup(const rwfs::path& filePath); + void decodeRestSoundFramesAndCleanup(const std::filesystem::path& filePath); void decodeRestSfxFramesAndCleanup(); /// Load sound from mp3/wav file - void loadFromFile(const rwfs::path& filePath, bool streaming = false); + void loadFromFile(const std::filesystem::path& filePath, bool streaming = false); /// Load sound from sdt file void loadSfx(LoaderSDT& sdt, std::size_t index, bool asWave = true, diff --git a/rwengine/src/engine/GameData.cpp b/rwengine/src/engine/GameData.cpp index 07d16910..831cf81b 100644 --- a/rwengine/src/engine/GameData.cpp +++ b/rwengine/src/engine/GameData.cpp @@ -33,7 +33,7 @@ #include "loaders/LoaderGXT.hpp" #include "platform/FileIndex.hpp" -GameData::GameData(Logger* log, const rwfs::path& path) +GameData::GameData(Logger* log, const std::filesystem::path& path) : datpath(path), logger(log) { dffLoader.setTextureLookupCallback( [&](const std::string& texture, const std::string&) { @@ -766,8 +766,8 @@ float GameData::getWaveHeightAt(const glm::vec3& ws) const { } bool GameData::isValidGameDirectory() const { - rwfs::error_code ec; - if (!rwfs::is_directory(datpath, ec)) { + std::error_code ec; + if (!std::filesystem::is_directory(datpath, ec)) { return false; } diff --git a/rwengine/src/engine/GameData.hpp b/rwengine/src/engine/GameData.hpp index e6148e8f..73093264 100644 --- a/rwengine/src/engine/GameData.hpp +++ b/rwengine/src/engine/GameData.hpp @@ -43,7 +43,7 @@ class SCMFile; */ class GameData { private: - rwfs::path datpath; + std::filesystem::path datpath; std::string splash; std::string currenttextureslot; @@ -55,7 +55,7 @@ public: * ctor * @param path Path to the root of the game data. */ - GameData(Logger* log, const rwfs::path& path); + GameData(Logger* log, const std::filesystem::path& path); ~GameData() = default; GameWorld* engine = nullptr; @@ -70,7 +70,7 @@ public: /** * Returns the game data path */ - const rwfs::path& getDataPath() const { + const std::filesystem::path& getDataPath() const { return datpath; } diff --git a/rwengine/src/engine/SaveGame.cpp b/rwengine/src/engine/SaveGame.cpp index 885d23ef..39206e17 100644 --- a/rwengine/src/engine/SaveGame.cpp +++ b/rwengine/src/engine/SaveGame.cpp @@ -4,11 +4,9 @@ #include #include #include - +#include #include -#include - #include #include @@ -1359,13 +1357,13 @@ std::vector SaveGame::getAllSaveGameInfo() { } const char gameDir[] = "GTA3 User Files"; - rwfs::path gamePath(homedir); + std::filesystem::path gamePath(homedir); gamePath /= gameDir; - if (!rwfs::exists(gamePath) || !rwfs::is_directory(gamePath)) return {}; + if (!std::filesystem::exists(gamePath) || !std::filesystem::is_directory(gamePath)) return {}; std::vector infos; - for (const rwfs::path& save_path : rwfs::directory_iterator(gamePath)) { + for (const std::filesystem::path& save_path : std::filesystem::directory_iterator(gamePath)) { if (save_path.extension() == ".b") { infos.emplace_back( SaveGameInfo{save_path.string(), false, BasicState()}); diff --git a/rwgame/GameBase.cpp b/rwgame/GameBase.cpp index 1d73f661..56f0c263 100644 --- a/rwgame/GameBase.cpp +++ b/rwgame/GameBase.cpp @@ -37,7 +37,7 @@ RWConfig GameBase::buildConfig(const std::optional &args) { auto defaultLayer = buildDefaultConfigLayer(); config.setLayer(RWConfig::LAYER_DEFAULT, defaultLayer); - rwfs::path configPath; + std::filesystem::path configPath; if (args.has_value() && args->configPath.has_value()) { configPath = *args->configPath; } else { diff --git a/rwgame/RWConfig.cpp b/rwgame/RWConfig.cpp index b0b63ef9..19d781fe 100644 --- a/rwgame/RWConfig.cpp +++ b/rwgame/RWConfig.cpp @@ -174,22 +174,22 @@ RWConfigLayer buildDefaultConfigLayer() { static constexpr auto kConfigDirectoryName = "OpenRW"; -rwfs::path RWConfigParser::getDefaultConfigPath() { +std::filesystem::path RWConfigParser::getDefaultConfigPath() { #if defined(RW_LINUX) || defined(RW_FREEBSD) || defined(RW_NETBSD) || \ defined(RW_OPENBSD) char *config_home = getenv("XDG_CONFIG_HOME"); if (config_home != nullptr) { - return rwfs::path(config_home) / kConfigDirectoryName; + return std::filesystem::path(config_home) / kConfigDirectoryName; } char *home = getenv("HOME"); if (home != nullptr) { - return rwfs::path(home) / ".config/" / kConfigDirectoryName; + return std::filesystem::path(home) / ".config/" / kConfigDirectoryName; } #elif defined(RW_OSX) char *home = getenv("HOME"); if (home) - return rwfs::path(home) / "Library/Preferences/" / kConfigDirectoryName; + return std::filesystem::path(home) / "Library/Preferences/" / kConfigDirectoryName; #elif defined(RW_WINDOWS) wchar_t *widePath; @@ -197,15 +197,15 @@ rwfs::path RWConfigParser::getDefaultConfigPath() { nullptr, &widePath); if (SUCCEEDED(res)) { auto utf8Path = wideStringToACP(widePath); - return rwfs::path(utf8Path) / kConfigDirectoryName; + return std::filesystem::path(utf8Path) / kConfigDirectoryName; } #else - return rwfs::path(); + return std::filesystem::path(); #endif // Well now we're stuck. RW_ERROR("No default config path found."); - return rwfs::path(); + return std::filesystem::path(); } namespace { @@ -406,7 +406,7 @@ TreeParser buildTreeParser() { } -std::tuple RWConfigParser::loadFile(const rwfs::path &path) const { +std::tuple RWConfigParser::loadFile(const std::filesystem::path &path) const { ParseResult parseResult(path.string(), ""); auto treeParser = buildTreeParser(); @@ -429,7 +429,8 @@ std::tuple RWConfigParser::loadFile( return std::make_tuple(layer, parseResult); } -RWConfigParser::ParseResult RWConfigParser::saveFile(const rwfs::path &path, const RWConfigLayer &layer, const std::map &extra) const { +RWConfigParser::ParseResult RWConfigParser::saveFile(const std::filesystem::path &path, + const RWConfigLayer &layer, const std::map &extra) const { ParseResult parseResult("", path.string()); auto treeParser = buildTreeParser(); @@ -454,7 +455,7 @@ RWConfigParser::ParseResult RWConfigParser::saveFile(const rwfs::path &path, con return parseResult; } -RWConfigParser::ParseResult RWConfigParser::saveFile(const rwfs::path &path, const RWConfigLayer &layer) const { +RWConfigParser::ParseResult RWConfigParser::saveFile(const std::filesystem::path &path, const RWConfigLayer &layer) const { ParseResult parseResult("", path.string()); auto treeParser = buildTreeParser(); diff --git a/rwgame/RWConfig.hpp b/rwgame/RWConfig.hpp index 2d498280..c26e3be5 100644 --- a/rwgame/RWConfig.hpp +++ b/rwgame/RWConfig.hpp @@ -1,11 +1,10 @@ #ifndef RWGAME_RWCONFIG_HPP #define RWGAME_RWCONFIG_HPP -#include - #include #include +#include #include #include #include @@ -243,13 +242,14 @@ public: */ RWConfigParser() = default; - static rwfs::path getDefaultConfigPath(); + static std::filesystem::path getDefaultConfigPath(); - std::tuple loadFile(const rwfs::path &path) const; + std::tuple loadFile(const std::filesystem::path &path) const; - ParseResult saveFile(const rwfs::path &path, const RWConfigLayer &layer) const; + ParseResult saveFile(const std::filesystem::path &path, const RWConfigLayer &layer) const; - ParseResult saveFile(const rwfs::path &path, const RWConfigLayer &layer, const std::map &extra) const; + ParseResult saveFile(const std::filesystem::path &path, const RWConfigLayer &layer, + const std::map &extra) const; /** * @brief layer_to_string Convert the layer to a INI string string diff --git a/rwgame/RWGame.cpp b/rwgame/RWGame.cpp index 36250c1d..e9aaa87e 100644 --- a/rwgame/RWGame.cpp +++ b/rwgame/RWGame.cpp @@ -98,7 +98,7 @@ RWGame::RWGame(Logger& log, const std::optional &args) btIDebugDraw::DBG_DrawConstraintLimits); debug.setShaderProgram(renderer.worldProg.get()); - data.loadDynamicObjects((rwfs::path{config.gamedataPath()} / "data/object.dat") + data.loadDynamicObjects((std::filesystem::path{config.gamedataPath()} / "data/object.dat") .string()); // FIXME: use path data.loadGXT("text/" + config.gameLanguage() + ".gxt"); diff --git a/rwtools/rwfont/rwfontmap.cpp b/rwtools/rwfont/rwfontmap.cpp index 8850ce03..fc3ec87c 100644 --- a/rwtools/rwfont/rwfontmap.cpp +++ b/rwtools/rwfont/rwfontmap.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include FT_FREETYPE_H @@ -12,6 +11,7 @@ #include #include +#include #include #include #include @@ -182,7 +182,7 @@ public: } } - void write(const rwfs::path &bitmap_path, const rwfs::path &advance_path) { + void write(const std::filesystem::path &bitmap_path, const std::filesystem::path &advance_path) { QImageWriter writer(QString::fromStdString(bitmap_path.string())); writer.write(m_texture); std::ofstream ofs(advance_path.string(), std::ios_base::out); @@ -219,8 +219,8 @@ int main(int argc, const char *argv[]) ("ratio,r", po::value()->value_name("ASPECTRATIO"), "Aspect ratio") ("map,m", po::value()->value_name("MAP")->required(), "Font map to use") ("font,f", po::value>()->value_name("PATH")->required(), "Path to fonts") - ("texture,t", po::value()->value_name("PATH")->required(), "Output texture") - ("advance,a", po::value()->value_name("PATH")->required(), "Output advances") + ("texture,t", po::value()->value_name("PATH")->required(), "Output texture") + ("advance,a", po::value()->value_name("PATH")->required(), "Output advances") ; po::variables_map vm; @@ -267,6 +267,6 @@ int main(int argc, const char *argv[]) texBuffer.create_font_map(fontmaps_gta3_font[fontmap_index], FontTextureBuffer::RenderMode::NORMAL); - texBuffer.write(vm["texture"].as(), vm["advance"].as()); + texBuffer.write(vm["texture"].as(), vm["advance"].as()); return 0; } diff --git a/rwviewer/views/TextViewer.cpp b/rwviewer/views/TextViewer.cpp index c7efa4f1..05865ef0 100644 --- a/rwviewer/views/TextViewer.cpp +++ b/rwviewer/views/TextViewer.cpp @@ -1,14 +1,13 @@ #include "TextViewer.hpp" #include -#include #include #include +#include #include #include -#include #include #include #include @@ -221,10 +220,10 @@ void TextViewer::worldChanged() { } std::vector TextViewer::getFontTextureNames() { - const auto &gameDataPath = rwfs::path(world()->data->getDataPath()); - rwfs::path textPath; - for (const rwfs::path &p : rwfs::directory_iterator(gameDataPath)) { - if (!rwfs::is_directory(p)) { + const auto &gameDataPath = std::filesystem::path(world()->data->getDataPath()); + std::filesystem::path textPath; + for (const std::filesystem::path &p : std::filesystem::directory_iterator(gameDataPath)) { + if (!std::filesystem::is_directory(p)) { continue; } std::string filename = p.filename().string(); @@ -238,7 +237,7 @@ std::vector TextViewer::getFontTextureNames() { throw std::runtime_error("text directory not found in gamedata path"); } std::vector names; - for (const rwfs::path &p : rwfs::directory_iterator(textPath)) { + for (const std::filesystem::path &p : std::filesystem::directory_iterator(textPath)) { // auto langName = p.lexically_relative(gameDataPath).string(); auto langName = p.filename().string(); std::transform(langName.begin(), langName.end(), langName.begin(), ::tolower); diff --git a/rwviewer/views/TextViewer.hpp b/rwviewer/views/TextViewer.hpp index 5666184f..0798b9e9 100644 --- a/rwviewer/views/TextViewer.hpp +++ b/rwviewer/views/TextViewer.hpp @@ -4,10 +4,10 @@ #include "ViewerInterface.hpp" #include -#include #include +#include #include class TextModel; diff --git a/scripts/docker/conan_base.docker b/scripts/docker/conan_base.docker index f1c4cad9..cd4c9242 100644 --- a/scripts/docker/conan_base.docker +++ b/scripts/docker/conan_base.docker @@ -5,9 +5,9 @@ RUN apt-get update \ build-essential \ cmake \ ninja-build \ - gcc-7 \ - g++-7 \ - clang-6.0 \ + gcc-8 \ + g++-8 \ + clang-7 \ llvm \ lcov \ curl \ @@ -66,9 +66,9 @@ RUN apt-get update \ libxinerama-dev \ libxkbcommon-dev \ && apt-get clean \ - && update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 60 \ - && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 \ - && update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-7 60 + && update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 60 \ + && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 60 \ + && update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-8 60 # RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 50 --slave /usr/bin/g++ g++ /usr/bin/g++-8 diff --git a/scripts/docker/ubuntu_latest.docker b/scripts/docker/ubuntu_latest.docker index 0851e67b..acf1456c 100644 --- a/scripts/docker/ubuntu_latest.docker +++ b/scripts/docker/ubuntu_latest.docker @@ -15,8 +15,8 @@ RUN apt-get update \ curl \ libavcodec-dev \ libavformat-dev \ - libboost-filesystem-dev \ libboost-program-options-dev \ + libboost-system-dev \ libbullet-dev \ libglm-dev \ libopenal-dev \ diff --git a/tests/test_Config.cpp b/tests/test_Config.cpp index f05ff059..5784c60f 100644 --- a/tests/test_Config.cpp +++ b/tests/test_Config.cpp @@ -5,19 +5,19 @@ #include #include +#include #include #include -#include +#include #include -#include namespace pt = boost::property_tree; typedef std::map> simpleConfig_t; -simpleConfig_t readConfig(const rwfs::path &path) { +simpleConfig_t readConfig(const std::filesystem::path &path) { simpleConfig_t cfg; pt::ptree tree; pt::read_ini(path.string(), tree); @@ -68,9 +68,9 @@ public: virtual ~Temp() { } bool exists() const { - return rwfs::exists(this->m_path); + return std::filesystem::exists(this->m_path); } - const rwfs::path &path() const { + const std::filesystem::path &path() const { return this->m_path; } std::string filename() const { @@ -88,18 +88,32 @@ protected: Temp(const Temp &) = delete; Temp() : m_path(getRandomFilePath()) { } - Temp(const rwfs::path &dirname) : m_path(getRandomFilePath(dirname)) { + Temp(const std::filesystem::path &dirname) : m_path(getRandomFilePath(dirname)) { } private: - static rwfs::path getRandomFilePath(const rwfs::path &dirname) { - const long current_time = std::chrono::high_resolution_clock::now().time_since_epoch().count(); - return dirname / ("openrw_test_" + std::to_string(current_time)); + static std::string gen_random(size_t len) { + constexpr std::string_view alphanum = + "0123456789" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz"; + std::default_random_engine reng(std::random_device{}()); + std::uniform_int_distribution dist(0u, alphanum.size()); + std::string res; + res.reserve(len); + std::generate_n(std::back_inserter(res), len, [&]() { + return alphanum[dist(reng)]; + }); + return res; } - static rwfs::path getRandomFilePath() { - return getRandomFilePath(rwfs::temp_directory_path()); + static std::filesystem::path getRandomFilePath(const std::filesystem::path &dirname) { + const std::string name = "openrw_test_" + gen_random(16); + return dirname / name; } - rwfs::path m_path; + static std::filesystem::path getRandomFilePath() { + return getRandomFilePath(std::filesystem::temp_directory_path()); + } + std::filesystem::path m_path; }; class TempFile; @@ -114,24 +128,24 @@ public: this->remove(); } virtual void change_perms_normal() const override { - rwfs::permissions(this->path(), - rwfs::perms::owner_read | rwfs::perms::owner_write | rwfs::perms::owner_exec | - rwfs::perms::group_read | rwfs::perms::group_exec | - rwfs::perms::others_read | rwfs::perms::others_exec); + std::filesystem::permissions(this->path(), + std::filesystem::perms::owner_read | std::filesystem::perms::owner_write | std::filesystem::perms::owner_exec | + std::filesystem::perms::group_read | std::filesystem::perms::group_exec | + std::filesystem::perms::others_read | std::filesystem::perms::others_exec); } virtual void change_perms_readonly() const override { - rwfs::permissions(this->path(), - rwfs::perms::owner_read | rwfs::perms::owner_exec | - rwfs::perms::group_read | rwfs::perms::group_exec | - rwfs::perms::others_read | rwfs::perms::others_exec); + std::filesystem::permissions(this->path(), + std::filesystem::perms::owner_read | std::filesystem::perms::owner_exec | + std::filesystem::perms::group_read | std::filesystem::perms::group_exec | + std::filesystem::perms::others_read | std::filesystem::perms::others_exec); } virtual void remove() const override { // Remove may fail if this directory contains a read-only entry. Ignore. - rwfs::error_code ec; - rwfs::remove_all(this->path(), ec); + std::error_code ec; + std::filesystem::remove_all(this->path(), ec); } void touch() const override { - rwfs::create_directories(this->path()); + std::filesystem::create_directories(this->path()); } friend class TempFile; }; @@ -146,19 +160,20 @@ public: this->remove(); } virtual void change_perms_normal() const override { - rwfs::permissions(this->path(), - rwfs::perms::owner_read | rwfs::perms::owner_write | - rwfs::perms::group_read | - rwfs::perms::others_read); + std::filesystem::permissions(this->path(), + std::filesystem::perms::owner_read | std::filesystem::perms::owner_write | + std::filesystem::perms::group_read | + std::filesystem::perms::others_read); } virtual void change_perms_readonly() const override { - rwfs::permissions(this->path(), rwfs::perms::owner_read | - rwfs::perms::group_read | - rwfs::perms::others_read); + std::filesystem::permissions(this->path(), + std::filesystem::perms::owner_read | + std::filesystem::perms::group_read | + std::filesystem::perms::others_read); } virtual void remove() const override { - rwfs::error_code ec; - rwfs::remove_all(this->path(), ec); + std::error_code ec; + std::filesystem::remove_all(this->path(), ec); } virtual void touch() const override { std::ofstream ofs(this->path().string(), std::ios::out | std::ios::app); @@ -225,14 +240,14 @@ BOOST_AUTO_TEST_CASE(test_TempDir) { tempChildDir.touch(); BOOST_CHECK(tempChildDir.exists()); - rwfs::path path; + std::filesystem::path path; { TempDir tempLocal; tempLocal.touch(); BOOST_CHECK(tempLocal.exists()); path = tempLocal.path(); } - BOOST_CHECK(!rwfs::exists(path)); + BOOST_CHECK(!std::filesystem::exists(path)); } BOOST_AUTO_TEST_CASE(test_TempFile) { @@ -261,14 +276,14 @@ BOOST_AUTO_TEST_CASE(test_TempFile) { BOOST_CHECK(!tempFile.write("abc")); BOOST_CHECK(!tempFile.append("def")); - rwfs::path path; + std::filesystem::path path; { TempFile tempLocal; tempLocal.touch(); BOOST_CHECK(tempLocal.exists()); path = tempLocal.path(); } - BOOST_CHECK(!rwfs::exists(path)); + BOOST_CHECK(!std::filesystem::exists(path)); } BOOST_AUTO_TEST_CASE(test_configParser_initial) { diff --git a/tests/test_FileIndex.cpp b/tests/test_FileIndex.cpp index 8ac9dfc0..a332b8c1 100644 --- a/tests/test_FileIndex.cpp +++ b/tests/test_FileIndex.cpp @@ -30,7 +30,7 @@ BOOST_AUTO_TEST_CASE(test_indexTree, DATA_TEST_PREDICATE) { auto truepath = index.findFilePath(upperpath); BOOST_ASSERT(!truepath.empty()); BOOST_CHECK(upperpath != truepath); - rwfs::path expected{Global::getGamePath()}; + std::filesystem::path expected{Global::getGamePath()}; expected /= "data/CULLZONE.DAT"; BOOST_CHECK(expected.compare(expected) == 0); } @@ -39,7 +39,7 @@ BOOST_AUTO_TEST_CASE(test_indexTree, DATA_TEST_PREDICATE) { auto truepath = index.findFilePath(upperpath); BOOST_ASSERT(!truepath.empty()); BOOST_CHECK(upperpath != truepath); - rwfs::path expected{Global::getGamePath()}; + std::filesystem::path expected{Global::getGamePath()}; expected /= "data/maps/comnbtm/comNbtm.ipl"; BOOST_CHECK(expected.compare(truepath) == 0); } diff --git a/tests/test_Globals.cpp b/tests/test_Globals.cpp index 7d57da2f..6c8968de 100644 --- a/tests/test_Globals.cpp +++ b/tests/test_Globals.cpp @@ -3,7 +3,7 @@ #include std::string Global::getGamePath() { - rwfs::path configPath = RWConfigParser::getDefaultConfigPath() / "openrw.ini"; + std::filesystem::path configPath = RWConfigParser::getDefaultConfigPath() / "openrw.ini"; RWConfigParser cfgParser; auto [cfgLayer, parseResult] = cfgParser.loadFile(configPath); BOOST_REQUIRE(parseResult.isValid());