From 421e4a23df295eb9b8c6f02e4ffe3686a6e5af05 Mon Sep 17 00:00:00 2001 From: Tomas Jakobsson Date: Mon, 29 Jan 2018 23:50:10 +0100 Subject: [PATCH] The final traces of boost has been eliminated --- CMakeLists.txt | 12 --- CREDITS.md | 3 - README.md | 7 +- es-app/CMakeLists.txt | 4 +- es-app/src/CollectionSystemManager.cpp | 23 +++--- es-app/src/FileData.cpp | 11 +-- es-app/src/FileData.h | 11 +-- es-app/src/Gamelist.cpp | 36 +++++---- es-app/src/MetaData.cpp | 8 +- es-app/src/MetaData.h | 6 +- es-app/src/SystemData.cpp | 78 ++++++++----------- es-app/src/SystemScreenSaver.cpp | 1 + es-app/src/guis/GuiGameScraper.cpp | 2 +- es-app/src/guis/GuiGamelistOptions.cpp | 2 +- es-app/src/guis/GuiMetaDataEd.cpp | 2 +- es-app/src/guis/GuiScraperMulti.cpp | 2 +- es-app/src/main.cpp | 2 +- es-app/src/scrapers/Scraper.cpp | 4 +- es-app/src/scrapers/Scraper.h | 4 + .../src/views/gamelist/BasicGameListView.cpp | 2 +- es-core/src/GuiComponent.cpp | 1 + es-core/src/HttpReq.h | 2 +- es-core/src/ThemeData.cpp | 39 +++------- es-core/src/ThemeData.h | 20 ++--- es-core/src/Window.cpp | 1 + es-core/src/components/VideoComponent.cpp | 5 +- es-core/src/components/VideoComponent.h | 7 +- .../src/components/VideoPlayerComponent.cpp | 1 + es-core/src/components/VideoVlcComponent.cpp | 6 +- es-core/src/utils/FileSystemUtil.cpp | 76 ++++++++++++------ es-core/src/utils/FileSystemUtil.h | 1 + 31 files changed, 182 insertions(+), 197 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7264ba474..66d06762e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,11 +49,6 @@ endif() find_package(Freetype REQUIRED) find_package(FreeImage REQUIRED) find_package(SDL2 REQUIRED) -if(MSVC) -find_package(Boost REQUIRED COMPONENTS system date_time) -else() -find_package(Boost REQUIRED COMPONENTS system filesystem date_time) -endif() find_package(CURL REQUIRED) find_package(VLC REQUIRED) find_package(libCEC) @@ -113,7 +108,6 @@ set(COMMON_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIRS} ${FreeImage_INCLUDE_DIRS} ${SDL2_INCLUDE_DIR} - ${Boost_INCLUDE_DIRS} ${CURL_INCLUDE_DIR} ${VLC_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/external @@ -157,17 +151,11 @@ endif() #define libraries and directories if(DEFINED BCMHOST) link_directories( - ${Boost_LIBRARY_DIRS} "/opt/vc/lib" ) -else() - link_directories( - ${Boost_LIBRARY_DIRS} - ) endif() set(COMMON_LIBRARIES - ${Boost_LIBRARIES} ${FREETYPE_LIBRARIES} ${FreeImage_LIBRARIES} ${SDL2_LIBRARY} diff --git a/CREDITS.md b/CREDITS.md index 49c70ddbc..babde810f 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -23,9 +23,6 @@ FreeType cURL http://curl.haxx.se/ -Boost - http://www.boost.org/ - nanosvg https://github.com/memononen/nanosvg diff --git a/README.md b/README.md index 5a300a00e..76908388e 100644 --- a/README.md +++ b/README.md @@ -9,13 +9,12 @@ Building EmulationStation uses some C++11 code, which means you'll need to use at least g++-4.7 on Linux, or VS2010 on Windows, to compile. -EmulationStation has a few dependencies. For building, you'll need CMake, SDL2, Boost (System, Filesystem, DateTime, Locale), FreeImage, FreeType, and cURL. You also should probably install the `fonts-droid` package which contains fallback fonts for Chinese/Japanese/Korean characters, but ES will still work fine without it (this package is only used at run-time). +EmulationStation has a few dependencies. For building, you'll need CMake, SDL2, FreeImage, FreeType, and cURL. You also should probably install the `fonts-droid` package which contains fallback fonts for Chinese/Japanese/Korean characters, but ES will still work fine without it (this package is only used at run-time). **On Debian/Ubuntu:** All of this be easily installed with apt-get: ```bash -sudo apt-get install libsdl2-dev libboost-system-dev libboost-filesystem-dev libboost-date-time-dev \ - libboost-locale-dev libfreeimage-dev libfreetype6-dev libcurl4-openssl-dev \ +sudo apt-get install libsdl2-dev libfreeimage-dev libfreetype6-dev libcurl4-openssl-dev \ libasound2-dev libgl1-mesa-dev build-essential cmake fonts-droid \ libvlc-dev libvlccore-dev vlc-nox ``` @@ -47,8 +46,6 @@ Complete Raspberry Pi build instructions at [emulationstation.org](http://emulat **On Windows:** -[Boost](http://www.boost.org/users/download/) (you'll need to compile yourself or get the pre-compiled binaries) - [FreeImage](http://downloads.sourceforge.net/freeimage/FreeImage3154Win32.zip) [FreeType2](http://download.savannah.gnu.org/releases/freetype/freetype-2.4.9.tar.bz2) (you'll need to compile) diff --git a/es-app/CMakeLists.txt b/es-app/CMakeLists.txt index 005c82488..ee3c644c4 100644 --- a/es-app/CMakeLists.txt +++ b/es-app/CMakeLists.txt @@ -155,8 +155,8 @@ SET(CPACK_RESOURCE_FILE README "${CMAKE_CURRENT_SOURCE_DIR}/README.md") SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Alec Lofquist ") SET(CPACK_DEBIAN_PACKAGE_SECTION "misc") SET(CPACK_DEBIAN_PACKAGE_PRIORITY "extra") -SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6, libsdl2-2.0-0, libboost-system${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}, libboost-filesystem${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}, libfreeimage3, libfreetype6, libcurl3, libasound2") -SET(CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS "debhelper (>= 8.0.0), cmake, g++ (>= 4.8), libsdl2-dev, libboost-system-dev, libboost-filesystem-dev, libboost-date-time-dev, libfreeimage-dev, libfreetype6-dev, libcurl4-openssl-dev, libasound2-dev, libgl1-mesa-dev") +SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6, libsdl2-2.0-0, libfreeimage3, libfreetype6, libcurl3, libasound2") +SET(CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS "debhelper (>= 8.0.0), cmake, g++ (>= 4.8), libsdl2-dev, libfreeimage-dev, libfreetype6-dev, libcurl4-openssl-dev, libasound2-dev, libgl1-mesa-dev") SET(CPACK_PACKAGE_VENDOR "emulationstation.org") SET(CPACK_PACKAGE_VERSION "2.0.0~rc1") diff --git a/es-app/src/CollectionSystemManager.cpp b/es-app/src/CollectionSystemManager.cpp index bba7930df..eb8162845 100644 --- a/es-app/src/CollectionSystemManager.cpp +++ b/es-app/src/CollectionSystemManager.cpp @@ -330,7 +330,7 @@ bool CollectionSystemManager::isThemeCustomCollectionCompatible(std::vectorgetString("ThemeSet")); if(set != themeSets.cend()) { - std::string defaultThemeFilePath = set->second.path.string() + "/theme.xml"; + std::string defaultThemeFilePath = set->second.path + "/theme.xml"; if (Utils::FileSystem::exists(defaultThemeFilePath)) { return true; @@ -879,11 +879,11 @@ std::vector CollectionSystemManager::getSystemsFromTheme() Settings::getInstance()->setString("ThemeSet", set->first); } - boost::filesystem::path themePath = set->second.path; + std::string themePath = set->second.path; - if (Utils::FileSystem::exists(themePath.generic_string())) + if (Utils::FileSystem::exists(themePath)) { - Utils::FileSystem::stringList dirContent = Utils::FileSystem::getDirContent(themePath.generic_string()); + Utils::FileSystem::stringList dirContent = Utils::FileSystem::getDirContent(themePath); for (Utils::FileSystem::stringList::const_iterator it = dirContent.cbegin(); it != dirContent.cend(); ++it) { @@ -891,9 +891,9 @@ std::vector CollectionSystemManager::getSystemsFromTheme() { //... here you have a directory std::string folder = *it; - folder = folder.substr(themePath.string().size()+1); + folder = folder.substr(themePath.size()+1); - if(Utils::FileSystem::exists(set->second.getThemePath(folder).generic_string())) + if(Utils::FileSystem::exists(set->second.getThemePath(folder))) { systems.push_back(folder); } @@ -940,18 +940,18 @@ std::vector CollectionSystemManager::getUnusedSystemsFromTheme() std::vector CollectionSystemManager::getCollectionsFromConfigFolder() { std::vector systems; - boost::filesystem::path configPath = getCollectionsFolder(); + std::string configPath = getCollectionsFolder(); - if (Utils::FileSystem::exists(configPath.generic_string())) + if (Utils::FileSystem::exists(configPath)) { - Utils::FileSystem::stringList dirContent = Utils::FileSystem::getDirContent(configPath.generic_string()); + Utils::FileSystem::stringList dirContent = Utils::FileSystem::getDirContent(configPath); for (Utils::FileSystem::stringList::const_iterator it = dirContent.cbegin(); it != dirContent.cend(); ++it) { if (Utils::FileSystem::isRegularFile(*it)) { // it's a file std::string file = *it; - std::string filename = file.substr(configPath.string().size()); + std::string filename = file.substr(configPath.size()); // need to confirm filename matches config format if (filename != "custom-.cfg" && Utils::String::startsWith(filename, "custom-") && Utils::String::endsWith(filename, ".cfg")) @@ -1013,8 +1013,7 @@ bool CollectionSystemManager::includeFileInAutoCollections(FileData* file) std::string getCustomCollectionConfigPath(std::string collectionName) { - boost::filesystem::path path = getCollectionsFolder() + "custom-" + collectionName + ".cfg"; - return path.generic_string(); + return getCollectionsFolder() + "custom-" + collectionName + ".cfg";; } std::string getCollectionsFolder() diff --git a/es-app/src/FileData.cpp b/es-app/src/FileData.cpp index 035932bd4..ebcf7b850 100644 --- a/es-app/src/FileData.cpp +++ b/es-app/src/FileData.cpp @@ -12,8 +12,9 @@ #include "SystemData.h" #include "VolumeControl.h" #include "Window.h" +#include -FileData::FileData(FileType type, const boost::filesystem::path& path, SystemEnvironmentData* envData, SystemData* system) +FileData::FileData(FileType type, const std::string& path, SystemEnvironmentData* envData, SystemData* system) : mType(type), mPath(path), mSystem(system), mEnvData(envData), mSourceFileData(NULL), mParent(NULL), metadata(type == GAME ? GAME_METADATA : FOLDER_METADATA) // metadata is REALLY set in the constructor! { // metadata needs at least a name field (since that's what getName() will return) @@ -35,7 +36,7 @@ FileData::~FileData() std::string FileData::getDisplayName() const { - std::string stem = mPath.stem().generic_string(); + std::string stem = Utils::FileSystem::getStem(mPath); if(mSystem && mSystem->hasPlatformId(PlatformIds::ARCADE) || mSystem->hasPlatformId(PlatformIds::NEOGEO)) stem = PlatformIds::mameTitleSearch(stem.c_str()); @@ -254,9 +255,9 @@ void FileData::launchGame(Window* window) std::string command = mEnvData->mLaunchCommand; - const std::string rom = Utils::FileSystem::getEscapedPath(getPath().generic_string()); - const std::string basename = getPath().stem().string(); - const std::string rom_raw = boost::filesystem::path(getPath()).make_preferred().string(); + const std::string rom = Utils::FileSystem::getEscapedPath(getPath()); + const std::string basename = Utils::FileSystem::getStem(getPath()); + const std::string rom_raw = getPath(); command = Utils::String::replace(command, "%ROM%", rom); command = Utils::String::replace(command, "%BASENAME%", basename); diff --git a/es-app/src/FileData.h b/es-app/src/FileData.h index 57a98b1a7..28a311b73 100644 --- a/es-app/src/FileData.h +++ b/es-app/src/FileData.h @@ -2,6 +2,7 @@ #ifndef ES_APP_FILE_DATA_H #define ES_APP_FILE_DATA_H +#include "utils/FileSystemUtil.h" #include "MetaData.h" #include @@ -32,12 +33,12 @@ FileType stringToFileType(const char* str); class FileData { public: - FileData(FileType type, const boost::filesystem::path& path, SystemEnvironmentData* envData, SystemData* system); + FileData(FileType type, const std::string& path, SystemEnvironmentData* envData, SystemData* system); virtual ~FileData(); virtual const std::string& getName(); inline FileType getType() const { return mType; } - inline const boost::filesystem::path& getPath() const { return mPath; } + inline const std::string& getPath() const { return mPath; } inline FileData* getParent() const { return mParent; } inline const std::unordered_map& getChildrenByFilename() const { return mChildrenByFilename; } inline const std::vector& getChildren() const { return mChildren; } @@ -59,8 +60,8 @@ public: virtual inline void refreshMetadata() { return; }; virtual std::string getKey(); - inline std::string getFullPath() { return getPath().string(); }; - inline std::string getFileName() { return getPath().filename().string(); }; + inline std::string getFullPath() { return getPath(); }; + inline std::string getFileName() { return Utils::FileSystem::getFileName(getPath()); }; virtual FileData* getSourceFileData(); inline std::string getSystemName() const { return mSystemName; }; @@ -94,7 +95,7 @@ protected: private: FileType mType; - boost::filesystem::path mPath; + std::string mPath; SystemEnvironmentData* mEnvData; SystemData* mSystem; std::unordered_map mChildrenByFilename; diff --git a/es-app/src/Gamelist.cpp b/es-app/src/Gamelist.cpp index 813d93938..784c28125 100644 --- a/es-app/src/Gamelist.cpp +++ b/es-app/src/Gamelist.cpp @@ -8,12 +8,12 @@ #include "SystemData.h" #include -FileData* findOrCreateFile(SystemData* system, const boost::filesystem::path& path, FileType type) +FileData* findOrCreateFile(SystemData* system, const std::string& path, FileType type) { // first, verify that path is within the system's root folder FileData* root = system->getRootFolder(); bool contains = false; - boost::filesystem::path relative = Utils::FileSystem::removeCommonPath(path.generic_string(), root->getPath().generic_string(), contains); + std::string relative = Utils::FileSystem::removeCommonPath(path, root->getPath(), contains); if(!contains) { @@ -21,21 +21,22 @@ FileData* findOrCreateFile(SystemData* system, const boost::filesystem::path& pa return NULL; } - auto path_it = relative.begin(); + Utils::FileSystem::stringList pathList = Utils::FileSystem::getPathList(relative); + auto path_it = pathList.begin(); FileData* treeNode = root; bool found = false; - while(path_it != relative.end()) + while(path_it != pathList.end()) { const std::unordered_map& children = treeNode->getChildrenByFilename(); - std::string key = path_it->string(); + std::string key = *path_it; found = children.find(key) != children.cend(); if (found) { treeNode = children.at(key); } // this is the end - if(path_it == --relative.end()) + if(path_it == --pathList.end()) { if(found) return treeNode; @@ -62,7 +63,7 @@ FileData* findOrCreateFile(SystemData* system, const boost::filesystem::path& pa } // create missing folder - FileData* folder = new FileData(FOLDER, treeNode->getPath().stem() / *path_it, system->getSystemEnvData(), system); + FileData* folder = new FileData(FOLDER, Utils::FileSystem::getStem(treeNode->getPath()) + "/" + *path_it, system->getSystemEnvData(), system); treeNode->addChild(folder); treeNode = folder; } @@ -75,6 +76,7 @@ FileData* findOrCreateFile(SystemData* system, const boost::filesystem::path& pa void parseGamelist(SystemData* system) { + bool trustGamelist = Settings::getInstance()->getBool("ParseGamelistOnly"); std::string xmlpath = system->getGamelistPath(false); if(!Utils::FileSystem::exists(xmlpath)) @@ -98,7 +100,7 @@ void parseGamelist(SystemData* system) return; } - boost::filesystem::path relativeTo = system->getStartPath(); + std::string relativeTo = system->getStartPath(); const char* tagList[2] = { "game", "folder" }; FileType typeList[2] = { GAME, FOLDER }; @@ -108,9 +110,9 @@ void parseGamelist(SystemData* system) FileType type = typeList[i]; for(pugi::xml_node fileNode = root.child(tag); fileNode; fileNode = fileNode.next_sibling(tag)) { - boost::filesystem::path path = Utils::FileSystem::resolveRelativePath(fileNode.child("path").text().get(), relativeTo.generic_string(), false); + const std::string path = Utils::FileSystem::resolveRelativePath(fileNode.child("path").text().get(), relativeTo, false); - if(!Utils::FileSystem::exists(path.generic_string())) + if(!trustGamelist && !Utils::FileSystem::exists(path)) { LOG(LogWarning) << "File \"" << path << "\" does not exist! Ignoring."; continue; @@ -155,7 +157,7 @@ void addFileDataNode(pugi::xml_node& parent, const FileData* file, const char* t //there's something useful in there so we'll keep the node, add the path // try and make the path relative if we can so things still work if we change the rom folder location in the future - newNode.prepend_child("path").text().set(Utils::FileSystem::createRelativePath(file->getPath().generic_string(), system->getStartPath(), false).c_str()); + newNode.prepend_child("path").text().set(Utils::FileSystem::createRelativePath(file->getPath(), system->getStartPath(), false).c_str()); } } @@ -229,9 +231,11 @@ void updateGamelist(SystemData* system) continue; } - boost::filesystem::path nodePath = Utils::FileSystem::resolveRelativePath(pathNode.text().get(), system->getStartPath(), true); - boost::filesystem::path gamePath((*fit)->getPath()); - if(nodePath == gamePath || (Utils::FileSystem::exists(nodePath.generic_string()) && Utils::FileSystem::exists(gamePath.generic_string()) && Utils::FileSystem::isEquivalent(nodePath.generic_string(), gamePath.generic_string()))) + std::string nodePath = Utils::FileSystem::resolveRelativePath(pathNode.text().get(), system->getStartPath(), true); + std::string gamePath = (*fit)->getPath(); + if(nodePath == gamePath || (Utils::FileSystem::exists(nodePath) && + Utils::FileSystem::exists(gamePath) && + Utils::FileSystem::isEquivalent(nodePath, gamePath))) { // found it root.remove_child(fileNode); @@ -248,8 +252,8 @@ void updateGamelist(SystemData* system) if (numUpdated > 0) { //make sure the folders leading up to this path exist (or the write will fail) - boost::filesystem::path xmlWritePath(system->getGamelistPath(true)); - Utils::FileSystem::createDirectory(xmlWritePath.parent_path().generic_string()); + std::string xmlWritePath(system->getGamelistPath(true)); + Utils::FileSystem::createDirectory(Utils::FileSystem::getParent(xmlWritePath)); LOG(LogInfo) << "Added/Updated " << numUpdated << " entities in '" << xmlReadPath << "'"; diff --git a/es-app/src/MetaData.cpp b/es-app/src/MetaData.cpp index 7732ac16b..4db852dde 100644 --- a/es-app/src/MetaData.cpp +++ b/es-app/src/MetaData.cpp @@ -67,7 +67,7 @@ MetaDataList::MetaDataList(MetaDataListType type) } -MetaDataList MetaDataList::createFromXML(MetaDataListType type, pugi::xml_node& node, const boost::filesystem::path& relativeTo) +MetaDataList MetaDataList::createFromXML(MetaDataListType type, pugi::xml_node& node, const std::string& relativeTo) { MetaDataList mdl(type); @@ -82,7 +82,7 @@ MetaDataList MetaDataList::createFromXML(MetaDataListType type, pugi::xml_node& std::string value = md.text().get(); if (iter->type == MD_PATH) { - value = Utils::FileSystem::resolveRelativePath(value, relativeTo.generic_string(), true); + value = Utils::FileSystem::resolveRelativePath(value, relativeTo, true); } mdl.set(iter->key, value); }else{ @@ -93,7 +93,7 @@ MetaDataList MetaDataList::createFromXML(MetaDataListType type, pugi::xml_node& return mdl; } -void MetaDataList::appendToXML(pugi::xml_node& parent, bool ignoreDefaults, const boost::filesystem::path& relativeTo) const +void MetaDataList::appendToXML(pugi::xml_node& parent, bool ignoreDefaults, const std::string& relativeTo) const { const std::vector& mdd = getMDD(); @@ -110,7 +110,7 @@ void MetaDataList::appendToXML(pugi::xml_node& parent, bool ignoreDefaults, cons // try and make paths relative if we can std::string value = mapIter->second; if (mddIter->type == MD_PATH) - value = Utils::FileSystem::createRelativePath(value, relativeTo.generic_string(), true); + value = Utils::FileSystem::createRelativePath(value, relativeTo, true); parent.append_child(mapIter->first.c_str()).text().set(value.c_str()); } diff --git a/es-app/src/MetaData.h b/es-app/src/MetaData.h index 7efdcda41..6ed8f6d44 100644 --- a/es-app/src/MetaData.h +++ b/es-app/src/MetaData.h @@ -2,8 +2,8 @@ #ifndef ES_APP_META_DATA_H #define ES_APP_META_DATA_H -#include #include +#include namespace pugi { class xml_node; } @@ -44,8 +44,8 @@ const std::vector& getMDDByType(MetaDataListType type); class MetaDataList { public: - static MetaDataList createFromXML(MetaDataListType type, pugi::xml_node& node, const boost::filesystem::path& relativeTo); - void appendToXML(pugi::xml_node& parent, bool ignoreDefaults, const boost::filesystem::path& relativeTo) const; + static MetaDataList createFromXML(MetaDataListType type, pugi::xml_node& node, const std::string& relativeTo); + void appendToXML(pugi::xml_node& parent, bool ignoreDefaults, const std::string& relativeTo) const; MetaDataList(MetaDataListType type); diff --git a/es-app/src/SystemData.cpp b/es-app/src/SystemData.cpp index 8a48f182d..1ecc274b7 100644 --- a/es-app/src/SystemData.cpp +++ b/es-app/src/SystemData.cpp @@ -67,55 +67,40 @@ void SystemData::setIsGameSystemStatus() mIsGameSystem = (mName != "retropie"); } -// test to see if a file is hidden -bool isHidden(const boost::filesystem::path &filePath) -{ -#ifdef WIN32 - const DWORD Attributes = GetFileAttributes(filePath.generic_string().c_str()); - return (Attributes != INVALID_FILE_ATTRIBUTES) && (Attributes & FILE_ATTRIBUTE_HIDDEN); -#else - boost::filesystem::path::string_type fileName = filePath.filename().string(); - return fileName[0] == '.'; -#endif -} - void SystemData::populateFolder(FileData* folder) { - const boost::filesystem::path& folderPath = folder->getPath(); - if(!Utils::FileSystem::isDirectory(folderPath.generic_string())) + const std::string& folderPath = folder->getPath(); + if(!Utils::FileSystem::isDirectory(folderPath)) { LOG(LogWarning) << "Error - folder with path \"" << folderPath << "\" is not a directory!"; return; } - const std::string folderStr = folderPath.generic_string(); - //make sure that this isn't a symlink to a thing we already have - if(Utils::FileSystem::isSymlink(folderPath.generic_string())) + if(Utils::FileSystem::isSymlink(folderPath)) { + Utils::FileSystem::getCanonicalPath("/RetroGames/roms/nes/garbage/../smurf.nes"); + //if this symlink resolves to somewhere that's at the beginning of our path, it's gonna recurse - if(folderStr.find(Utils::FileSystem::getCanonicalPath(folderPath.generic_string())) == 0) + if(folderPath.find(Utils::FileSystem::getCanonicalPath(folderPath)) == 0) { LOG(LogWarning) << "Skipping infinitely recursive symlink \"" << folderPath << "\""; return; } } - boost::filesystem::path filePath; + std::string filePath; std::string extension; bool isGame; bool showHidden = Settings::getInstance()->getBool("ShowHiddenFiles"); - Utils::FileSystem::stringList dirContent = Utils::FileSystem::getDirContent(folderPath.generic_string()); + Utils::FileSystem::stringList dirContent = Utils::FileSystem::getDirContent(folderPath); for(Utils::FileSystem::stringList::const_iterator it = dirContent.cbegin(); it != dirContent.cend(); ++it) { filePath = *it; - if(filePath.stem().empty()) - continue; - //this is a little complicated because we allow a list of extensions to be defined (delimited with a space) //we first get the extension of the file itself: - extension = filePath.extension().string(); + extension = Utils::FileSystem::getExtension(filePath); //fyi, folders *can* also match the extension and be added as games - this is mostly just to support higan //see issue #75: https://github.com/Aloshi/EmulationStation/issues/75 @@ -124,18 +109,18 @@ void SystemData::populateFolder(FileData* folder) if(std::find(mEnvData->mSearchExtensions.cbegin(), mEnvData->mSearchExtensions.cend(), extension) != mEnvData->mSearchExtensions.cend()) { // skip hidden files - if(!showHidden && isHidden(filePath)) + if(!showHidden && Utils::FileSystem::isHidden(filePath)) continue; - FileData* newGame = new FileData(GAME, filePath.generic_string(), mEnvData, this); + FileData* newGame = new FileData(GAME, filePath, mEnvData, this); folder->addChild(newGame); isGame = true; } //add directories that also do not match an extension as folders - if(!isGame && Utils::FileSystem::isDirectory(filePath.generic_string())) + if(!isGame && Utils::FileSystem::isDirectory(filePath)) { - FileData* newFolder = new FileData(FOLDER, filePath.generic_string(), mEnvData, this); + FileData* newFolder = new FileData(FOLDER, filePath, mEnvData, this); populateFolder(newFolder); //ignore folders that do not contain games @@ -261,8 +246,7 @@ bool SystemData::loadConfig() } //convert path to generic directory seperators - boost::filesystem::path genericPath(path); - path = genericPath.generic_string(); + path = Utils::FileSystem::getGenericPath(path); //expand home symbol if the startpath contains ~ if(path[0] == '~') @@ -349,9 +333,9 @@ void SystemData::deleteSystems() std::string SystemData::getConfigPath(bool forWrite) { - boost::filesystem::path path = Utils::FileSystem::getHomePath() + "/.emulationstation/es_systems.cfg"; - if(forWrite || Utils::FileSystem::exists(path.generic_string())) - return path.generic_string(); + std::string path = Utils::FileSystem::getHomePath() + "/.emulationstation/es_systems.cfg"; + if(forWrite || Utils::FileSystem::exists(path)) + return path; return "/etc/emulationstation/es_systems.cfg"; } @@ -386,17 +370,17 @@ SystemData* SystemData::getPrev() const std::string SystemData::getGamelistPath(bool forWrite) const { - boost::filesystem::path filePath; + std::string filePath; - filePath = mRootFolder->getPath() / "gamelist.xml"; - if(Utils::FileSystem::exists(filePath.generic_string())) - return filePath.generic_string(); + filePath = mRootFolder->getPath() + "/gamelist.xml"; + if(Utils::FileSystem::exists(filePath)) + return filePath; filePath = Utils::FileSystem::getHomePath() + "/.emulationstation/gamelists/" + mName + "/gamelist.xml"; if(forWrite) // make sure the directory exists if we're going to write to it, or crashes will happen - Utils::FileSystem::createDirectory(filePath.parent_path().generic_string()); - if(forWrite || Utils::FileSystem::exists(filePath.generic_string())) - return filePath.generic_string(); + Utils::FileSystem::createDirectory(Utils::FileSystem::getParent(filePath)); + if(forWrite || Utils::FileSystem::exists(filePath)) + return filePath; return "/etc/emulationstation/gamelists/" + mName + "/gamelist.xml"; } @@ -409,20 +393,20 @@ std::string SystemData::getThemePath() const // 3. default system theme from currently selected theme set [CURRENT_THEME_PATH]/theme.xml // first, check game folder - boost::filesystem::path localThemePath = mRootFolder->getPath() / "theme.xml"; - if(Utils::FileSystem::exists(localThemePath.generic_string())) - return localThemePath.generic_string(); + std::string localThemePath = mRootFolder->getPath() + "/theme.xml"; + if(Utils::FileSystem::exists(localThemePath)) + return localThemePath; // not in game folder, try system theme in theme sets localThemePath = ThemeData::getThemeFromCurrentSet(mThemeFolder); - if (Utils::FileSystem::exists(localThemePath.generic_string())) - return localThemePath.generic_string(); + if (Utils::FileSystem::exists(localThemePath)) + return localThemePath; // not system theme, try default system theme in theme set - localThemePath = localThemePath.parent_path().parent_path() / "theme.xml"; + localThemePath = Utils::FileSystem::getParent(Utils::FileSystem::getParent(localThemePath)) + "/theme.xml"; - return localThemePath.generic_string(); + return localThemePath; } bool SystemData::hasGamelist() const diff --git a/es-app/src/SystemScreenSaver.cpp b/es-app/src/SystemScreenSaver.cpp index e5ee92454..3fde90109 100644 --- a/es-app/src/SystemScreenSaver.cpp +++ b/es-app/src/SystemScreenSaver.cpp @@ -16,6 +16,7 @@ #include "SystemData.h" #include #include +#include #define FADE_TIME 300 diff --git a/es-app/src/guis/GuiGameScraper.cpp b/es-app/src/guis/GuiGameScraper.cpp index b2674a78b..d8ebcb716 100644 --- a/es-app/src/guis/GuiGameScraper.cpp +++ b/es-app/src/guis/GuiGameScraper.cpp @@ -19,7 +19,7 @@ GuiGameScraper::GuiGameScraper(Window* window, ScraperSearchParams params, std:: // row 0 is a spacer - mGameName = std::make_shared(mWindow, Utils::String::toUpper(mSearchParams.game->getPath().filename().generic_string()), + mGameName = std::make_shared(mWindow, Utils::String::toUpper(Utils::FileSystem::getFileName(mSearchParams.game->getPath())), Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_CENTER); mGrid.setEntry(mGameName, Vector2i(0, 1), false, true); diff --git a/es-app/src/guis/GuiGamelistOptions.cpp b/es-app/src/guis/GuiGamelistOptions.cpp index 52950bcf6..501881656 100644 --- a/es-app/src/guis/GuiGamelistOptions.cpp +++ b/es-app/src/guis/GuiGamelistOptions.cpp @@ -194,7 +194,7 @@ void GuiGamelistOptions::openMetaDataEd() }; } - mWindow->pushGui(new GuiMetaDataEd(mWindow, &file->metadata, file->metadata.getMDD(), p, file->getPath().filename().string(), + mWindow->pushGui(new GuiMetaDataEd(mWindow, &file->metadata, file->metadata.getMDD(), p, Utils::FileSystem::getFileName(file->getPath()), std::bind(&IGameListView::onFileChanged, ViewController::get()->getGameListView(file->getSystem()).get(), file, FILE_METADATA_CHANGED), deleteBtnFunc)); } diff --git a/es-app/src/guis/GuiMetaDataEd.cpp b/es-app/src/guis/GuiMetaDataEd.cpp index d7021f090..fcf780774 100644 --- a/es-app/src/guis/GuiMetaDataEd.cpp +++ b/es-app/src/guis/GuiMetaDataEd.cpp @@ -36,7 +36,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, MetaDataList* md, const std::vector mHeaderGrid = std::make_shared(mWindow, Vector2i(1, 5)); mTitle = std::make_shared(mWindow, "EDIT METADATA", Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER); - mSubtitle = std::make_shared(mWindow, Utils::String::toUpper(scraperParams.game->getPath().filename().generic_string()), + mSubtitle = std::make_shared(mWindow, Utils::String::toUpper(Utils::FileSystem::getFileName(scraperParams.game->getPath())), Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER); mHeaderGrid->setEntry(mTitle, Vector2i(0, 1), false, true); mHeaderGrid->setEntry(mSubtitle, Vector2i(0, 3), false, true); diff --git a/es-app/src/guis/GuiScraperMulti.cpp b/es-app/src/guis/GuiScraperMulti.cpp index 3dc546d83..28b87db40 100644 --- a/es-app/src/guis/GuiScraperMulti.cpp +++ b/es-app/src/guis/GuiScraperMulti.cpp @@ -103,7 +103,7 @@ void GuiScraperMulti::doNextSearch() // update subtitle ss.str(""); // clear - ss << "GAME " << (mCurrentGame + 1) << " OF " << mTotalGames << " - " << Utils::String::toUpper(mSearchQueue.front().game->getPath().filename().string()); + ss << "GAME " << (mCurrentGame + 1) << " OF " << mTotalGames << " - " << Utils::String::toUpper(Utils::FileSystem::getFileName(mSearchQueue.front().game->getPath())); mSubtitle->setText(ss.str()); mSearchComp->search(mSearchQueue.front()); diff --git a/es-app/src/main.cpp b/es-app/src/main.cpp index 5c119dde8..f1a69c5eb 100644 --- a/es-app/src/main.cpp +++ b/es-app/src/main.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #ifdef WIN32 #include #endif @@ -220,7 +221,6 @@ int main(int argc, char* argv[]) srand((unsigned int)time(NULL)); std::locale::global(std::locale("C")); - boost::filesystem::path::imbue(std::locale()); if(!parseArgs(argc, argv)) return 0; diff --git a/es-app/src/scrapers/Scraper.cpp b/es-app/src/scrapers/Scraper.cpp index b7f16552c..17eb8bc8b 100644 --- a/es-app/src/scrapers/Scraper.cpp +++ b/es-app/src/scrapers/Scraper.cpp @@ -1,10 +1,8 @@ #include "scrapers/Scraper.h" -#include "utils/FileSystemUtil.h" #include "FileData.h" #include "GamesDBScraper.h" #include "Log.h" -#include "platform.h" #include "Settings.h" #include "SystemData.h" #include @@ -274,7 +272,7 @@ bool resizeImage(const std::string& path, int maxWidth, int maxHeight) std::string getSaveAsPath(const ScraperSearchParams& params, const std::string& suffix, const std::string& url) { const std::string subdirectory = params.system->getName(); - const std::string name = params.game->getPath().stem().generic_string() + "-" + suffix; + const std::string name = Utils::FileSystem::getStem(params.game->getPath()) + "-" + suffix; std::string path = Utils::FileSystem::getHomePath() + "/.emulationstation/downloaded_images/"; diff --git a/es-app/src/scrapers/Scraper.h b/es-app/src/scrapers/Scraper.h index c22344637..013ad5e54 100644 --- a/es-app/src/scrapers/Scraper.h +++ b/es-app/src/scrapers/Scraper.h @@ -5,7 +5,11 @@ #include "AsyncHandle.h" #include "HttpReq.h" #include "MetaData.h" +#include +#include #include +#include +#include #define MAX_SCRAPER_RESULTS 7 diff --git a/es-app/src/views/gamelist/BasicGameListView.cpp b/es-app/src/views/gamelist/BasicGameListView.cpp index 4f61d3fa8..4e479f317 100644 --- a/es-app/src/views/gamelist/BasicGameListView.cpp +++ b/es-app/src/views/gamelist/BasicGameListView.cpp @@ -105,7 +105,7 @@ void BasicGameListView::launch(FileData* game) void BasicGameListView::remove(FileData *game, bool deleteFile) { if (deleteFile) - Utils::FileSystem::removeFile(game->getPath().generic_string()); // actually delete the file on the filesystem + Utils::FileSystem::removeFile(game->getPath()); // actually delete the file on the filesystem FileData* parent = game->getParent(); if (getCursor() == game) // Select next element in list, or prev if none { diff --git a/es-core/src/GuiComponent.cpp b/es-core/src/GuiComponent.cpp index 5d9379fe8..9b7d22aa2 100644 --- a/es-core/src/GuiComponent.cpp +++ b/es-core/src/GuiComponent.cpp @@ -6,6 +6,7 @@ #include "Renderer.h" #include "ThemeData.h" #include "Window.h" +#include GuiComponent::GuiComponent(Window* window) : mWindow(window), mParent(NULL), mOpacity(255), mPosition(Vector3f::Zero()), mOrigin(Vector2f::Zero()), mRotationOrigin(0.5, 0.5), diff --git a/es-core/src/HttpReq.h b/es-core/src/HttpReq.h index d5c55b420..238efc544 100644 --- a/es-core/src/HttpReq.h +++ b/es-core/src/HttpReq.h @@ -35,7 +35,7 @@ public: REQ_IN_PROGRESS, //request is in progress REQ_SUCCESS, //request completed successfully, get it with getContent() - REQ_IO_ERROR, //some boost::asio error happened, get it with getErrorMsg() + REQ_IO_ERROR, //some error happened, get it with getErrorMsg() REQ_BAD_STATUS_CODE, //some invalid HTTP response status code happened (non-200) REQ_INVALID_RESPONSE //the HTTP response was invalid }; diff --git a/es-core/src/ThemeData.cpp b/es-core/src/ThemeData.cpp index 613af3d22..63dc72b23 100644 --- a/es-core/src/ThemeData.cpp +++ b/es-core/src/ThemeData.cpp @@ -7,6 +7,7 @@ #include "platform.h" #include "Settings.h" #include +#include std::vector ThemeData::sSupportedViews { { "system" }, { "basic" }, { "detailed" }, { "video" } }; std::vector ThemeData::sSupportedFeatures { { "video" }, { "carousel" }, { "z-index" } }; @@ -148,29 +149,6 @@ unsigned int getHexColor(const char* str) return val; } -// helper -std::string resolvePath(const char* in, const boost::filesystem::path& relative) -{ - if(!in || in[0] == '\0') - return in; - - boost::filesystem::path relPath = relative.parent_path(); - - boost::filesystem::path path(in); - - // we use boost filesystem here instead of just string checks because - // some directories could theoretically start with ~ or . - if(*path.begin() == "~") - { - path = Utils::FileSystem::getHomePath() + (in + 1); - }else if(*path.begin() == ".") - { - path = relPath / (in + 1); - } - - return path.generic_string(); -} - std::map mVariables; std::string resolvePlaceholders(const char* in) @@ -245,7 +223,7 @@ void ThemeData::parseIncludes(const pugi::xml_node& root) for(pugi::xml_node node = root.child("include"); node; node = node.next_sibling("include")) { const char* relPath = node.text().get(); - std::string path = resolvePath(relPath, mPaths.back()); + std::string path = Utils::FileSystem::resolveRelativePath(relPath, mPaths.back(), true); if(!ResourceManager::getInstance()->fileExists(path)) throw error << "Included file \"" << relPath << "\" not found! (resolved to \"" << path << "\")"; @@ -412,7 +390,7 @@ void ThemeData::parseElement(const pugi::xml_node& root, const std::mapfileExists(path)) { std::stringstream ss; @@ -535,17 +513,18 @@ std::map ThemeData::getThemeSets() std::map sets; static const size_t pathCount = 2; - boost::filesystem::path paths[pathCount] = { + std::string paths[pathCount] = + { "/etc/emulationstation/themes", Utils::FileSystem::getHomePath() + "/.emulationstation/themes" }; for(size_t i = 0; i < pathCount; i++) { - if(!Utils::FileSystem::isDirectory(paths[i].generic_string())) + if(!Utils::FileSystem::isDirectory(paths[i])) continue; - Utils::FileSystem::stringList dirContent = Utils::FileSystem::getDirContent(paths[i].generic_string()); + Utils::FileSystem::stringList dirContent = Utils::FileSystem::getDirContent(paths[i]); for(Utils::FileSystem::stringList::const_iterator it = dirContent.cbegin(); it != dirContent.cend(); ++it) { @@ -560,9 +539,9 @@ std::map ThemeData::getThemeSets() return sets; } -boost::filesystem::path ThemeData::getThemeFromCurrentSet(const std::string& system) +std::string ThemeData::getThemeFromCurrentSet(const std::string& system) { - auto themeSets = ThemeData::getThemeSets(); + std::map themeSets = ThemeData::getThemeSets(); if(themeSets.empty()) { // no theme sets available diff --git a/es-core/src/ThemeData.h b/es-core/src/ThemeData.h index 34e6a5c9d..4fc9faa74 100644 --- a/es-core/src/ThemeData.h +++ b/es-core/src/ThemeData.h @@ -3,10 +3,12 @@ #define ES_CORE_THEME_DATA_H #include "math/Vector2f.h" -#include +#include "utils/FileSystemUtil.h" #include #include +#include #include +#include namespace pugi { class xml_node; } @@ -53,11 +55,11 @@ public: template friend ThemeException& operator<<(ThemeException& e, T msg); - inline void setFiles(const std::deque& deque) + inline void setFiles(const std::deque& deque) { - *this << "from theme \"" << deque.front().string() << "\"\n"; + *this << "from theme \"" << deque.front() << "\"\n"; for(auto it = deque.cbegin() + 1; it != deque.cend(); it++) - *this << " (from included file \"" << (*it).string() << "\")\n"; + *this << " (from included file \"" << (*it) << "\")\n"; *this << " "; } }; @@ -73,10 +75,10 @@ ThemeException& operator<<(ThemeException& e, T appendMsg) struct ThemeSet { - boost::filesystem::path path; + std::string path; - inline std::string getName() const { return path.stem().string(); } - inline boost::filesystem::path getThemePath(const std::string& system) const { return path/system/"theme.xml"; } + inline std::string getName() const { return Utils::FileSystem::getStem(path); } + inline std::string getThemePath(const std::string& system) const { return path + "/" + system + "/theme.xml"; } }; class ThemeData @@ -155,14 +157,14 @@ public: static const std::shared_ptr& getDefault(); static std::map getThemeSets(); - static boost::filesystem::path getThemeFromCurrentSet(const std::string& system); + static std::string getThemeFromCurrentSet(const std::string& system); private: static std::map< std::string, std::map > sElementMap; static std::vector sSupportedFeatures; static std::vector sSupportedViews; - std::deque mPaths; + std::deque mPaths; float mVersion; void parseFeatures(const pugi::xml_node& themeRoot); diff --git a/es-core/src/Window.cpp b/es-core/src/Window.cpp index 47a8cd622..b43d567e6 100644 --- a/es-core/src/Window.cpp +++ b/es-core/src/Window.cpp @@ -7,6 +7,7 @@ #include "InputManager.h" #include "Log.h" #include "Renderer.h" +#include #include Window::Window() : mNormalizeNextUpdate(false), mFrameTimeElapsed(0), mFrameCountElapsed(0), mAverageDeltaTime(10), diff --git a/es-core/src/components/VideoComponent.cpp b/es-core/src/components/VideoComponent.cpp index 315319c65..6cd5f082a 100644 --- a/es-core/src/components/VideoComponent.cpp +++ b/es-core/src/components/VideoComponent.cpp @@ -101,8 +101,7 @@ void VideoComponent::onSizeChanged() bool VideoComponent::setVideo(std::string path) { // Convert the path into a generic format - boost::filesystem::path fullPath = Utils::FileSystem::getCanonicalPath(path); - fullPath.make_preferred().native(); + std::string fullPath = Utils::FileSystem::getCanonicalPath(path); // Check that it's changed if (fullPath == mVideoPath) @@ -112,7 +111,7 @@ bool VideoComponent::setVideo(std::string path) mVideoPath = fullPath; // If the file exists then set the new video - if (!fullPath.empty() && ResourceManager::getInstance()->fileExists(fullPath.generic_string())) + if (!fullPath.empty() && ResourceManager::getInstance()->fileExists(fullPath)) { // Return true to show that we are going to attempt to play a video return true; diff --git a/es-core/src/components/VideoComponent.h b/es-core/src/components/VideoComponent.h index 97f2dfc35..8d8207b1c 100644 --- a/es-core/src/components/VideoComponent.h +++ b/es-core/src/components/VideoComponent.h @@ -4,7 +4,6 @@ #include "components/ImageComponent.h" #include "GuiComponent.h" -#include #include class TextureResource; @@ -91,14 +90,14 @@ private: protected: unsigned mVideoWidth; unsigned mVideoHeight; - Vector2f mTargetSize; + Vector2f mTargetSize; std::shared_ptr mTexture; float mFadeIn; std::string mStaticImagePath; ImageComponent mStaticImage; - boost::filesystem::path mVideoPath; - boost::filesystem::path mPlayingVideoPath; + std::string mVideoPath; + std::string mPlayingVideoPath; bool mStartDelayed; unsigned mStartTime; bool mIsPlaying; diff --git a/es-core/src/components/VideoPlayerComponent.cpp b/es-core/src/components/VideoPlayerComponent.cpp index 8f0ef8df2..12cbba08f 100644 --- a/es-core/src/components/VideoPlayerComponent.cpp +++ b/es-core/src/components/VideoPlayerComponent.cpp @@ -6,6 +6,7 @@ #include "Renderer.h" #include "Settings.h" #include +#include #include class VolumeControl diff --git a/es-core/src/components/VideoVlcComponent.cpp b/es-core/src/components/VideoVlcComponent.cpp index 94fc0e81b..91f7532e4 100644 --- a/es-core/src/components/VideoVlcComponent.cpp +++ b/es-core/src/components/VideoVlcComponent.cpp @@ -1,6 +1,7 @@ #include "components/VideoVlcComponent.h" #include "resources/TextureResource.h" +#include "utils/StringUtil.h" #include "PowerSaver.h" #include "Renderer.h" #include "Settings.h" @@ -282,10 +283,9 @@ void VideoVlcComponent::startVideo() mVideoHeight = 0; #ifdef WIN32 - std::wstring_convert, wchar_t> wton; - std::string path = wton.to_bytes(mVideoPath.c_str()); + std::string path(Utils::String::replace(mVideoPath, "/", "\\")); #else - std::string path(mVideoPath.c_str()); + std::string path(mVideoPath); #endif // Make sure we have a video path if (mVLC && (path.size() > 0)) diff --git a/es-core/src/utils/FileSystemUtil.cpp b/es-core/src/utils/FileSystemUtil.cpp index 0d6ac65e5..5618695c6 100644 --- a/es-core/src/utils/FileSystemUtil.cpp +++ b/es-core/src/utils/FileSystemUtil.cpp @@ -22,6 +22,21 @@ namespace Utils { namespace FileSystem { + +#if defined(_WIN32) + static std::string convertFromWideString(const std::wstring wstring) + { + int numBytes = WideCharToMultiByte(CP_UTF8, 0, wstring.c_str(), (int)wstring.length(), nullptr, 0, nullptr, nullptr); + std::string string; + + string.resize(numBytes); + WideCharToMultiByte(CP_UTF8, 0, wstring.c_str(), (int)wstring.length(), (char*)string.c_str(), numBytes, nullptr, nullptr); + + return std::string(string); + + } // convertFromWideString +#endif // _WIN32 + stringList getDirContent(const std::string& _path, const bool _recursive) { std::string path = getGenericPath(_path); @@ -32,15 +47,16 @@ namespace Utils { #if defined(_WIN32) - WIN32_FIND_DATA findData; - HANDLE hFind = FindFirstFile((path + "/*").c_str(), &findData); + WIN32_FIND_DATAW findData; + std::string wildcard = path + "/*"; + HANDLE hFind = FindFirstFileW(std::wstring(wildcard.begin(), wildcard.end()).c_str(), &findData); if(hFind != INVALID_HANDLE_VALUE) { // loop over all files in the directory do { - std::string name(findData.cFileName); + std::string name = convertFromWideString(findData.cFileName); // ignore "." and ".." if((name != ".") && (name != "..")) @@ -52,7 +68,7 @@ namespace Utils contentList.merge(getDirContent(fullName, true)); } } - while(FindNextFile(hFind, &findData)); + while(FindNextFileW(hFind, &findData)); FindClose(hFind); } @@ -93,6 +109,31 @@ namespace Utils } // getDirContent + stringList getPathList(const std::string& _path) + { + stringList pathList; + std::string path = getGenericPath(_path); + size_t start = 0; + size_t end = 0; + + // split at '/' + while((end = path.find("/", start)) != std::string::npos) + { + if(end != start) + pathList.push_back(std::string(path, start, end - start)); + + start = end + 1; + } + + // add last folder / file to pathList + if(start != path.size()) + pathList.push_back(std::string(path, start, path.size() - start)); + + // return the path list + return pathList; + + } // getPathList + std::string getHomePath() { static std::string path; @@ -202,20 +243,7 @@ namespace Utils bool scan = true; while(scan) { - stringList pathList; - size_t start = 0; - size_t end = 0; - - // split at '/' - while((end = path.find("/", start)) != std::string::npos) - { - pathList.push_back(std::string(path, start, end - start)); - start = end + 1; - } - - // add last folder / file to pathList - if(start != path.size()) - pathList.push_back(std::string(path, start, path.size() - start)); + stringList pathList = getPathList(path); path.clear(); scan = false; @@ -356,12 +384,12 @@ namespace Utils return path; // replace '.' with relativeTo - if(path[0] == '.') - return (relativeTo + "/" + &(path[1])); + if((path[0] == '.') && (path[1] == '/')) + return (relativeTo + &(path[1])); // replace '~' with homePath - if(_allowHome && (path[0] == '~')) - return (getHomePath() + "/" + &(path[1])); + if(_allowHome && (path[0] == '~') && (path[1] == '/')) + return (getHomePath() + &(path[1])); // nothing to resolve return path; @@ -376,7 +404,7 @@ namespace Utils if(contains) { // success - return ("." + path); + return ("./" + path); } if(_allowHome) @@ -386,7 +414,7 @@ namespace Utils if(contains) { // success - return ("~" + path); + return ("~/" + path); } } diff --git a/es-core/src/utils/FileSystemUtil.h b/es-core/src/utils/FileSystemUtil.h index da623f55c..42373d694 100644 --- a/es-core/src/utils/FileSystemUtil.h +++ b/es-core/src/utils/FileSystemUtil.h @@ -12,6 +12,7 @@ namespace Utils typedef std::list stringList; stringList getDirContent (const std::string& _path, const bool _recursive = false); + stringList getPathList (const std::string& _path); std::string getHomePath (); std::string getCWDPath (); std::string getGenericPath (const std::string& _path);