The final traces of boost has been eliminated

This commit is contained in:
Tomas Jakobsson 2018-01-29 23:50:10 +01:00
parent e569ed7b88
commit 421e4a23df
31 changed files with 182 additions and 197 deletions

View file

@ -49,11 +49,6 @@ endif()
find_package(Freetype REQUIRED) find_package(Freetype REQUIRED)
find_package(FreeImage REQUIRED) find_package(FreeImage REQUIRED)
find_package(SDL2 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(CURL REQUIRED)
find_package(VLC REQUIRED) find_package(VLC REQUIRED)
find_package(libCEC) find_package(libCEC)
@ -113,7 +108,6 @@ set(COMMON_INCLUDE_DIRS
${FREETYPE_INCLUDE_DIRS} ${FREETYPE_INCLUDE_DIRS}
${FreeImage_INCLUDE_DIRS} ${FreeImage_INCLUDE_DIRS}
${SDL2_INCLUDE_DIR} ${SDL2_INCLUDE_DIR}
${Boost_INCLUDE_DIRS}
${CURL_INCLUDE_DIR} ${CURL_INCLUDE_DIR}
${VLC_INCLUDE_DIR} ${VLC_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/external ${CMAKE_CURRENT_SOURCE_DIR}/external
@ -157,17 +151,11 @@ endif()
#define libraries and directories #define libraries and directories
if(DEFINED BCMHOST) if(DEFINED BCMHOST)
link_directories( link_directories(
${Boost_LIBRARY_DIRS}
"/opt/vc/lib" "/opt/vc/lib"
) )
else()
link_directories(
${Boost_LIBRARY_DIRS}
)
endif() endif()
set(COMMON_LIBRARIES set(COMMON_LIBRARIES
${Boost_LIBRARIES}
${FREETYPE_LIBRARIES} ${FREETYPE_LIBRARIES}
${FreeImage_LIBRARIES} ${FreeImage_LIBRARIES}
${SDL2_LIBRARY} ${SDL2_LIBRARY}

View file

@ -23,9 +23,6 @@ FreeType
cURL cURL
http://curl.haxx.se/ http://curl.haxx.se/
Boost
http://www.boost.org/
nanosvg nanosvg
https://github.com/memononen/nanosvg https://github.com/memononen/nanosvg

View file

@ -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 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:** **On Debian/Ubuntu:**
All of this be easily installed with apt-get: All of this be easily installed with apt-get:
```bash ```bash
sudo apt-get install libsdl2-dev libboost-system-dev libboost-filesystem-dev libboost-date-time-dev \ sudo apt-get install libsdl2-dev libfreeimage-dev libfreetype6-dev libcurl4-openssl-dev \
libboost-locale-dev libfreeimage-dev libfreetype6-dev libcurl4-openssl-dev \
libasound2-dev libgl1-mesa-dev build-essential cmake fonts-droid \ libasound2-dev libgl1-mesa-dev build-essential cmake fonts-droid \
libvlc-dev libvlccore-dev vlc-nox libvlc-dev libvlccore-dev vlc-nox
``` ```
@ -47,8 +46,6 @@ Complete Raspberry Pi build instructions at [emulationstation.org](http://emulat
**On Windows:** **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) [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) [FreeType2](http://download.savannah.gnu.org/releases/freetype/freetype-2.4.9.tar.bz2) (you'll need to compile)

View file

@ -155,8 +155,8 @@ SET(CPACK_RESOURCE_FILE README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Alec Lofquist <allofquist@yahoo.com>") SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Alec Lofquist <allofquist@yahoo.com>")
SET(CPACK_DEBIAN_PACKAGE_SECTION "misc") SET(CPACK_DEBIAN_PACKAGE_SECTION "misc")
SET(CPACK_DEBIAN_PACKAGE_PRIORITY "extra") 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_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, 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_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_VENDOR "emulationstation.org")
SET(CPACK_PACKAGE_VERSION "2.0.0~rc1") SET(CPACK_PACKAGE_VERSION "2.0.0~rc1")

View file

@ -330,7 +330,7 @@ bool CollectionSystemManager::isThemeCustomCollectionCompatible(std::vector<std:
auto set = themeSets.find(Settings::getInstance()->getString("ThemeSet")); auto set = themeSets.find(Settings::getInstance()->getString("ThemeSet"));
if(set != themeSets.cend()) 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)) if (Utils::FileSystem::exists(defaultThemeFilePath))
{ {
return true; return true;
@ -879,11 +879,11 @@ std::vector<std::string> CollectionSystemManager::getSystemsFromTheme()
Settings::getInstance()->setString("ThemeSet", set->first); 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) for (Utils::FileSystem::stringList::const_iterator it = dirContent.cbegin(); it != dirContent.cend(); ++it)
{ {
@ -891,9 +891,9 @@ std::vector<std::string> CollectionSystemManager::getSystemsFromTheme()
{ {
//... here you have a directory //... here you have a directory
std::string folder = *it; 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); systems.push_back(folder);
} }
@ -940,18 +940,18 @@ std::vector<std::string> CollectionSystemManager::getUnusedSystemsFromTheme()
std::vector<std::string> CollectionSystemManager::getCollectionsFromConfigFolder() std::vector<std::string> CollectionSystemManager::getCollectionsFromConfigFolder()
{ {
std::vector<std::string> systems; std::vector<std::string> 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) for (Utils::FileSystem::stringList::const_iterator it = dirContent.cbegin(); it != dirContent.cend(); ++it)
{ {
if (Utils::FileSystem::isRegularFile(*it)) if (Utils::FileSystem::isRegularFile(*it))
{ {
// it's a file // it's a file
std::string file = *it; 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 // need to confirm filename matches config format
if (filename != "custom-.cfg" && Utils::String::startsWith(filename, "custom-") && Utils::String::endsWith(filename, ".cfg")) 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) std::string getCustomCollectionConfigPath(std::string collectionName)
{ {
boost::filesystem::path path = getCollectionsFolder() + "custom-" + collectionName + ".cfg"; return getCollectionsFolder() + "custom-" + collectionName + ".cfg";;
return path.generic_string();
} }
std::string getCollectionsFolder() std::string getCollectionsFolder()

View file

@ -12,8 +12,9 @@
#include "SystemData.h" #include "SystemData.h"
#include "VolumeControl.h" #include "VolumeControl.h"
#include "Window.h" #include "Window.h"
#include <assert.h>
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! : 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) // 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 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)) if(mSystem && mSystem->hasPlatformId(PlatformIds::ARCADE) || mSystem->hasPlatformId(PlatformIds::NEOGEO))
stem = PlatformIds::mameTitleSearch(stem.c_str()); stem = PlatformIds::mameTitleSearch(stem.c_str());
@ -254,9 +255,9 @@ void FileData::launchGame(Window* window)
std::string command = mEnvData->mLaunchCommand; std::string command = mEnvData->mLaunchCommand;
const std::string rom = Utils::FileSystem::getEscapedPath(getPath().generic_string()); const std::string rom = Utils::FileSystem::getEscapedPath(getPath());
const std::string basename = getPath().stem().string(); const std::string basename = Utils::FileSystem::getStem(getPath());
const std::string rom_raw = boost::filesystem::path(getPath()).make_preferred().string(); const std::string rom_raw = getPath();
command = Utils::String::replace(command, "%ROM%", rom); command = Utils::String::replace(command, "%ROM%", rom);
command = Utils::String::replace(command, "%BASENAME%", basename); command = Utils::String::replace(command, "%BASENAME%", basename);

View file

@ -2,6 +2,7 @@
#ifndef ES_APP_FILE_DATA_H #ifndef ES_APP_FILE_DATA_H
#define ES_APP_FILE_DATA_H #define ES_APP_FILE_DATA_H
#include "utils/FileSystemUtil.h"
#include "MetaData.h" #include "MetaData.h"
#include <unordered_map> #include <unordered_map>
@ -32,12 +33,12 @@ FileType stringToFileType(const char* str);
class FileData class FileData
{ {
public: 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 ~FileData();
virtual const std::string& getName(); virtual const std::string& getName();
inline FileType getType() const { return mType; } 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 FileData* getParent() const { return mParent; }
inline const std::unordered_map<std::string, FileData*>& getChildrenByFilename() const { return mChildrenByFilename; } inline const std::unordered_map<std::string, FileData*>& getChildrenByFilename() const { return mChildrenByFilename; }
inline const std::vector<FileData*>& getChildren() const { return mChildren; } inline const std::vector<FileData*>& getChildren() const { return mChildren; }
@ -59,8 +60,8 @@ public:
virtual inline void refreshMetadata() { return; }; virtual inline void refreshMetadata() { return; };
virtual std::string getKey(); virtual std::string getKey();
inline std::string getFullPath() { return getPath().string(); }; inline std::string getFullPath() { return getPath(); };
inline std::string getFileName() { return getPath().filename().string(); }; inline std::string getFileName() { return Utils::FileSystem::getFileName(getPath()); };
virtual FileData* getSourceFileData(); virtual FileData* getSourceFileData();
inline std::string getSystemName() const { return mSystemName; }; inline std::string getSystemName() const { return mSystemName; };
@ -94,7 +95,7 @@ protected:
private: private:
FileType mType; FileType mType;
boost::filesystem::path mPath; std::string mPath;
SystemEnvironmentData* mEnvData; SystemEnvironmentData* mEnvData;
SystemData* mSystem; SystemData* mSystem;
std::unordered_map<std::string,FileData*> mChildrenByFilename; std::unordered_map<std::string,FileData*> mChildrenByFilename;

View file

@ -8,12 +8,12 @@
#include "SystemData.h" #include "SystemData.h"
#include <pugixml/src/pugixml.hpp> #include <pugixml/src/pugixml.hpp>
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 // first, verify that path is within the system's root folder
FileData* root = system->getRootFolder(); FileData* root = system->getRootFolder();
bool contains = false; 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) if(!contains)
{ {
@ -21,21 +21,22 @@ FileData* findOrCreateFile(SystemData* system, const boost::filesystem::path& pa
return NULL; return NULL;
} }
auto path_it = relative.begin(); Utils::FileSystem::stringList pathList = Utils::FileSystem::getPathList(relative);
auto path_it = pathList.begin();
FileData* treeNode = root; FileData* treeNode = root;
bool found = false; bool found = false;
while(path_it != relative.end()) while(path_it != pathList.end())
{ {
const std::unordered_map<std::string, FileData*>& children = treeNode->getChildrenByFilename(); const std::unordered_map<std::string, FileData*>& children = treeNode->getChildrenByFilename();
std::string key = path_it->string(); std::string key = *path_it;
found = children.find(key) != children.cend(); found = children.find(key) != children.cend();
if (found) { if (found) {
treeNode = children.at(key); treeNode = children.at(key);
} }
// this is the end // this is the end
if(path_it == --relative.end()) if(path_it == --pathList.end())
{ {
if(found) if(found)
return treeNode; return treeNode;
@ -62,7 +63,7 @@ FileData* findOrCreateFile(SystemData* system, const boost::filesystem::path& pa
} }
// create missing folder // 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->addChild(folder);
treeNode = folder; treeNode = folder;
} }
@ -75,6 +76,7 @@ FileData* findOrCreateFile(SystemData* system, const boost::filesystem::path& pa
void parseGamelist(SystemData* system) void parseGamelist(SystemData* system)
{ {
bool trustGamelist = Settings::getInstance()->getBool("ParseGamelistOnly");
std::string xmlpath = system->getGamelistPath(false); std::string xmlpath = system->getGamelistPath(false);
if(!Utils::FileSystem::exists(xmlpath)) if(!Utils::FileSystem::exists(xmlpath))
@ -98,7 +100,7 @@ void parseGamelist(SystemData* system)
return; return;
} }
boost::filesystem::path relativeTo = system->getStartPath(); std::string relativeTo = system->getStartPath();
const char* tagList[2] = { "game", "folder" }; const char* tagList[2] = { "game", "folder" };
FileType typeList[2] = { GAME, FOLDER }; FileType typeList[2] = { GAME, FOLDER };
@ -108,9 +110,9 @@ void parseGamelist(SystemData* system)
FileType type = typeList[i]; FileType type = typeList[i];
for(pugi::xml_node fileNode = root.child(tag); fileNode; fileNode = fileNode.next_sibling(tag)) 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."; LOG(LogWarning) << "File \"" << path << "\" does not exist! Ignoring.";
continue; 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 //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 // 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; continue;
} }
boost::filesystem::path nodePath = Utils::FileSystem::resolveRelativePath(pathNode.text().get(), system->getStartPath(), true); std::string nodePath = Utils::FileSystem::resolveRelativePath(pathNode.text().get(), system->getStartPath(), true);
boost::filesystem::path gamePath((*fit)->getPath()); std::string 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()))) if(nodePath == gamePath || (Utils::FileSystem::exists(nodePath) &&
Utils::FileSystem::exists(gamePath) &&
Utils::FileSystem::isEquivalent(nodePath, gamePath)))
{ {
// found it // found it
root.remove_child(fileNode); root.remove_child(fileNode);
@ -248,8 +252,8 @@ void updateGamelist(SystemData* system)
if (numUpdated > 0) { if (numUpdated > 0) {
//make sure the folders leading up to this path exist (or the write will fail) //make sure the folders leading up to this path exist (or the write will fail)
boost::filesystem::path xmlWritePath(system->getGamelistPath(true)); std::string xmlWritePath(system->getGamelistPath(true));
Utils::FileSystem::createDirectory(xmlWritePath.parent_path().generic_string()); Utils::FileSystem::createDirectory(Utils::FileSystem::getParent(xmlWritePath));
LOG(LogInfo) << "Added/Updated " << numUpdated << " entities in '" << xmlReadPath << "'"; LOG(LogInfo) << "Added/Updated " << numUpdated << " entities in '" << xmlReadPath << "'";

View file

@ -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); MetaDataList mdl(type);
@ -82,7 +82,7 @@ MetaDataList MetaDataList::createFromXML(MetaDataListType type, pugi::xml_node&
std::string value = md.text().get(); std::string value = md.text().get();
if (iter->type == MD_PATH) 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); mdl.set(iter->key, value);
}else{ }else{
@ -93,7 +93,7 @@ MetaDataList MetaDataList::createFromXML(MetaDataListType type, pugi::xml_node&
return mdl; 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<MetaDataDecl>& mdd = getMDD(); const std::vector<MetaDataDecl>& mdd = getMDD();
@ -110,7 +110,7 @@ void MetaDataList::appendToXML(pugi::xml_node& parent, bool ignoreDefaults, cons
// try and make paths relative if we can // try and make paths relative if we can
std::string value = mapIter->second; std::string value = mapIter->second;
if (mddIter->type == MD_PATH) 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()); parent.append_child(mapIter->first.c_str()).text().set(value.c_str());
} }

View file

@ -2,8 +2,8 @@
#ifndef ES_APP_META_DATA_H #ifndef ES_APP_META_DATA_H
#define ES_APP_META_DATA_H #define ES_APP_META_DATA_H
#include <boost/filesystem/path.hpp>
#include <map> #include <map>
#include <vector>
namespace pugi { class xml_node; } namespace pugi { class xml_node; }
@ -44,8 +44,8 @@ const std::vector<MetaDataDecl>& getMDDByType(MetaDataListType type);
class MetaDataList class MetaDataList
{ {
public: public:
static MetaDataList createFromXML(MetaDataListType type, pugi::xml_node& node, const boost::filesystem::path& relativeTo); static MetaDataList createFromXML(MetaDataListType type, pugi::xml_node& node, const std::string& relativeTo);
void appendToXML(pugi::xml_node& parent, bool ignoreDefaults, const boost::filesystem::path& relativeTo) const; void appendToXML(pugi::xml_node& parent, bool ignoreDefaults, const std::string& relativeTo) const;
MetaDataList(MetaDataListType type); MetaDataList(MetaDataListType type);

View file

@ -67,55 +67,40 @@ void SystemData::setIsGameSystemStatus()
mIsGameSystem = (mName != "retropie"); 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) void SystemData::populateFolder(FileData* folder)
{ {
const boost::filesystem::path& folderPath = folder->getPath(); const std::string& folderPath = folder->getPath();
if(!Utils::FileSystem::isDirectory(folderPath.generic_string())) if(!Utils::FileSystem::isDirectory(folderPath))
{ {
LOG(LogWarning) << "Error - folder with path \"" << folderPath << "\" is not a directory!"; LOG(LogWarning) << "Error - folder with path \"" << folderPath << "\" is not a directory!";
return; return;
} }
const std::string folderStr = folderPath.generic_string();
//make sure that this isn't a symlink to a thing we already have //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 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 << "\""; LOG(LogWarning) << "Skipping infinitely recursive symlink \"" << folderPath << "\"";
return; return;
} }
} }
boost::filesystem::path filePath; std::string filePath;
std::string extension; std::string extension;
bool isGame; bool isGame;
bool showHidden = Settings::getInstance()->getBool("ShowHiddenFiles"); 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) for(Utils::FileSystem::stringList::const_iterator it = dirContent.cbegin(); it != dirContent.cend(); ++it)
{ {
filePath = *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) //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: //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 //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 //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()) if(std::find(mEnvData->mSearchExtensions.cbegin(), mEnvData->mSearchExtensions.cend(), extension) != mEnvData->mSearchExtensions.cend())
{ {
// skip hidden files // skip hidden files
if(!showHidden && isHidden(filePath)) if(!showHidden && Utils::FileSystem::isHidden(filePath))
continue; continue;
FileData* newGame = new FileData(GAME, filePath.generic_string(), mEnvData, this); FileData* newGame = new FileData(GAME, filePath, mEnvData, this);
folder->addChild(newGame); folder->addChild(newGame);
isGame = true; isGame = true;
} }
//add directories that also do not match an extension as folders //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); populateFolder(newFolder);
//ignore folders that do not contain games //ignore folders that do not contain games
@ -261,8 +246,7 @@ bool SystemData::loadConfig()
} }
//convert path to generic directory seperators //convert path to generic directory seperators
boost::filesystem::path genericPath(path); path = Utils::FileSystem::getGenericPath(path);
path = genericPath.generic_string();
//expand home symbol if the startpath contains ~ //expand home symbol if the startpath contains ~
if(path[0] == '~') if(path[0] == '~')
@ -349,9 +333,9 @@ void SystemData::deleteSystems()
std::string SystemData::getConfigPath(bool forWrite) std::string SystemData::getConfigPath(bool forWrite)
{ {
boost::filesystem::path path = Utils::FileSystem::getHomePath() + "/.emulationstation/es_systems.cfg"; std::string path = Utils::FileSystem::getHomePath() + "/.emulationstation/es_systems.cfg";
if(forWrite || Utils::FileSystem::exists(path.generic_string())) if(forWrite || Utils::FileSystem::exists(path))
return path.generic_string(); return path;
return "/etc/emulationstation/es_systems.cfg"; return "/etc/emulationstation/es_systems.cfg";
} }
@ -386,17 +370,17 @@ SystemData* SystemData::getPrev() const
std::string SystemData::getGamelistPath(bool forWrite) const std::string SystemData::getGamelistPath(bool forWrite) const
{ {
boost::filesystem::path filePath; std::string filePath;
filePath = mRootFolder->getPath() / "gamelist.xml"; filePath = mRootFolder->getPath() + "/gamelist.xml";
if(Utils::FileSystem::exists(filePath.generic_string())) if(Utils::FileSystem::exists(filePath))
return filePath.generic_string(); return filePath;
filePath = Utils::FileSystem::getHomePath() + "/.emulationstation/gamelists/" + mName + "/gamelist.xml"; 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 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()); Utils::FileSystem::createDirectory(Utils::FileSystem::getParent(filePath));
if(forWrite || Utils::FileSystem::exists(filePath.generic_string())) if(forWrite || Utils::FileSystem::exists(filePath))
return filePath.generic_string(); return filePath;
return "/etc/emulationstation/gamelists/" + mName + "/gamelist.xml"; 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 // 3. default system theme from currently selected theme set [CURRENT_THEME_PATH]/theme.xml
// first, check game folder // first, check game folder
boost::filesystem::path localThemePath = mRootFolder->getPath() / "theme.xml"; std::string localThemePath = mRootFolder->getPath() + "/theme.xml";
if(Utils::FileSystem::exists(localThemePath.generic_string())) if(Utils::FileSystem::exists(localThemePath))
return localThemePath.generic_string(); return localThemePath;
// not in game folder, try system theme in theme sets // not in game folder, try system theme in theme sets
localThemePath = ThemeData::getThemeFromCurrentSet(mThemeFolder); localThemePath = ThemeData::getThemeFromCurrentSet(mThemeFolder);
if (Utils::FileSystem::exists(localThemePath.generic_string())) if (Utils::FileSystem::exists(localThemePath))
return localThemePath.generic_string(); return localThemePath;
// not system theme, try default system theme in theme set // 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 bool SystemData::hasGamelist() const

View file

@ -16,6 +16,7 @@
#include "SystemData.h" #include "SystemData.h"
#include <pugixml/src/pugixml.hpp> #include <pugixml/src/pugixml.hpp>
#include <unordered_map> #include <unordered_map>
#include <time.h>
#define FADE_TIME 300 #define FADE_TIME 300

View file

@ -19,7 +19,7 @@ GuiGameScraper::GuiGameScraper(Window* window, ScraperSearchParams params, std::
// row 0 is a spacer // row 0 is a spacer
mGameName = std::make_shared<TextComponent>(mWindow, Utils::String::toUpper(mSearchParams.game->getPath().filename().generic_string()), mGameName = std::make_shared<TextComponent>(mWindow, Utils::String::toUpper(Utils::FileSystem::getFileName(mSearchParams.game->getPath())),
Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_CENTER); Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_CENTER);
mGrid.setEntry(mGameName, Vector2i(0, 1), false, true); mGrid.setEntry(mGameName, Vector2i(0, 1), false, true);

View file

@ -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)); std::bind(&IGameListView::onFileChanged, ViewController::get()->getGameListView(file->getSystem()).get(), file, FILE_METADATA_CHANGED), deleteBtnFunc));
} }

View file

@ -36,7 +36,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, MetaDataList* md, const std::vector
mHeaderGrid = std::make_shared<ComponentGrid>(mWindow, Vector2i(1, 5)); mHeaderGrid = std::make_shared<ComponentGrid>(mWindow, Vector2i(1, 5));
mTitle = std::make_shared<TextComponent>(mWindow, "EDIT METADATA", Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER); mTitle = std::make_shared<TextComponent>(mWindow, "EDIT METADATA", Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER);
mSubtitle = std::make_shared<TextComponent>(mWindow, Utils::String::toUpper(scraperParams.game->getPath().filename().generic_string()), mSubtitle = std::make_shared<TextComponent>(mWindow, Utils::String::toUpper(Utils::FileSystem::getFileName(scraperParams.game->getPath())),
Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER); Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER);
mHeaderGrid->setEntry(mTitle, Vector2i(0, 1), false, true); mHeaderGrid->setEntry(mTitle, Vector2i(0, 1), false, true);
mHeaderGrid->setEntry(mSubtitle, Vector2i(0, 3), false, true); mHeaderGrid->setEntry(mSubtitle, Vector2i(0, 3), false, true);

View file

@ -103,7 +103,7 @@ void GuiScraperMulti::doNextSearch()
// update subtitle // update subtitle
ss.str(""); // clear 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()); mSubtitle->setText(ss.str());
mSearchComp->search(mSearchQueue.front()); mSearchComp->search(mSearchQueue.front());

View file

@ -19,6 +19,7 @@
#include <SDL_main.h> #include <SDL_main.h>
#include <SDL_timer.h> #include <SDL_timer.h>
#include <iostream> #include <iostream>
#include <time.h>
#ifdef WIN32 #ifdef WIN32
#include <Windows.h> #include <Windows.h>
#endif #endif
@ -220,7 +221,6 @@ int main(int argc, char* argv[])
srand((unsigned int)time(NULL)); srand((unsigned int)time(NULL));
std::locale::global(std::locale("C")); std::locale::global(std::locale("C"));
boost::filesystem::path::imbue(std::locale());
if(!parseArgs(argc, argv)) if(!parseArgs(argc, argv))
return 0; return 0;

View file

@ -1,10 +1,8 @@
#include "scrapers/Scraper.h" #include "scrapers/Scraper.h"
#include "utils/FileSystemUtil.h"
#include "FileData.h" #include "FileData.h"
#include "GamesDBScraper.h" #include "GamesDBScraper.h"
#include "Log.h" #include "Log.h"
#include "platform.h"
#include "Settings.h" #include "Settings.h"
#include "SystemData.h" #include "SystemData.h"
#include <FreeImage.h> #include <FreeImage.h>
@ -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) std::string getSaveAsPath(const ScraperSearchParams& params, const std::string& suffix, const std::string& url)
{ {
const std::string subdirectory = params.system->getName(); 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/"; std::string path = Utils::FileSystem::getHomePath() + "/.emulationstation/downloaded_images/";

View file

@ -5,7 +5,11 @@
#include "AsyncHandle.h" #include "AsyncHandle.h"
#include "HttpReq.h" #include "HttpReq.h"
#include "MetaData.h" #include "MetaData.h"
#include <functional>
#include <memory>
#include <queue> #include <queue>
#include <utility>
#include <assert.h>
#define MAX_SCRAPER_RESULTS 7 #define MAX_SCRAPER_RESULTS 7

View file

@ -105,7 +105,7 @@ void BasicGameListView::launch(FileData* game)
void BasicGameListView::remove(FileData *game, bool deleteFile) void BasicGameListView::remove(FileData *game, bool deleteFile)
{ {
if (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(); FileData* parent = game->getParent();
if (getCursor() == game) // Select next element in list, or prev if none if (getCursor() == game) // Select next element in list, or prev if none
{ {

View file

@ -6,6 +6,7 @@
#include "Renderer.h" #include "Renderer.h"
#include "ThemeData.h" #include "ThemeData.h"
#include "Window.h" #include "Window.h"
#include <algorithm>
GuiComponent::GuiComponent(Window* window) : mWindow(window), mParent(NULL), mOpacity(255), GuiComponent::GuiComponent(Window* window) : mWindow(window), mParent(NULL), mOpacity(255),
mPosition(Vector3f::Zero()), mOrigin(Vector2f::Zero()), mRotationOrigin(0.5, 0.5), mPosition(Vector3f::Zero()), mOrigin(Vector2f::Zero()), mRotationOrigin(0.5, 0.5),

View file

@ -35,7 +35,7 @@ public:
REQ_IN_PROGRESS, //request is in progress REQ_IN_PROGRESS, //request is in progress
REQ_SUCCESS, //request completed successfully, get it with getContent() 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_BAD_STATUS_CODE, //some invalid HTTP response status code happened (non-200)
REQ_INVALID_RESPONSE //the HTTP response was invalid REQ_INVALID_RESPONSE //the HTTP response was invalid
}; };

View file

@ -7,6 +7,7 @@
#include "platform.h" #include "platform.h"
#include "Settings.h" #include "Settings.h"
#include <pugixml/src/pugixml.hpp> #include <pugixml/src/pugixml.hpp>
#include <algorithm>
std::vector<std::string> ThemeData::sSupportedViews { { "system" }, { "basic" }, { "detailed" }, { "video" } }; std::vector<std::string> ThemeData::sSupportedViews { { "system" }, { "basic" }, { "detailed" }, { "video" } };
std::vector<std::string> ThemeData::sSupportedFeatures { { "video" }, { "carousel" }, { "z-index" } }; std::vector<std::string> ThemeData::sSupportedFeatures { { "video" }, { "carousel" }, { "z-index" } };
@ -148,29 +149,6 @@ unsigned int getHexColor(const char* str)
return val; 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<std::string, std::string> mVariables; std::map<std::string, std::string> mVariables;
std::string resolvePlaceholders(const char* in) 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")) for(pugi::xml_node node = root.child("include"); node; node = node.next_sibling("include"))
{ {
const char* relPath = node.text().get(); 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)) if(!ResourceManager::getInstance()->fileExists(path))
throw error << "Included file \"" << relPath << "\" not found! (resolved to \"" << 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::map<std::str
break; break;
case PATH: case PATH:
{ {
std::string path = resolvePath(str.c_str(), mPaths.back().string()); std::string path = Utils::FileSystem::resolveRelativePath(str, mPaths.back(), true);
if(!ResourceManager::getInstance()->fileExists(path)) if(!ResourceManager::getInstance()->fileExists(path))
{ {
std::stringstream ss; std::stringstream ss;
@ -535,17 +513,18 @@ std::map<std::string, ThemeSet> ThemeData::getThemeSets()
std::map<std::string, ThemeSet> sets; std::map<std::string, ThemeSet> sets;
static const size_t pathCount = 2; static const size_t pathCount = 2;
boost::filesystem::path paths[pathCount] = { std::string paths[pathCount] =
{
"/etc/emulationstation/themes", "/etc/emulationstation/themes",
Utils::FileSystem::getHomePath() + "/.emulationstation/themes" Utils::FileSystem::getHomePath() + "/.emulationstation/themes"
}; };
for(size_t i = 0; i < pathCount; i++) for(size_t i = 0; i < pathCount; i++)
{ {
if(!Utils::FileSystem::isDirectory(paths[i].generic_string())) if(!Utils::FileSystem::isDirectory(paths[i]))
continue; 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) for(Utils::FileSystem::stringList::const_iterator it = dirContent.cbegin(); it != dirContent.cend(); ++it)
{ {
@ -560,9 +539,9 @@ std::map<std::string, ThemeSet> ThemeData::getThemeSets()
return sets; 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<std::string, ThemeSet> themeSets = ThemeData::getThemeSets();
if(themeSets.empty()) if(themeSets.empty())
{ {
// no theme sets available // no theme sets available

View file

@ -3,10 +3,12 @@
#define ES_CORE_THEME_DATA_H #define ES_CORE_THEME_DATA_H
#include "math/Vector2f.h" #include "math/Vector2f.h"
#include <boost/filesystem/path.hpp> #include "utils/FileSystemUtil.h"
#include <deque> #include <deque>
#include <map> #include <map>
#include <memory>
#include <sstream> #include <sstream>
#include <vector>
namespace pugi { class xml_node; } namespace pugi { class xml_node; }
@ -53,11 +55,11 @@ public:
template<typename T> template<typename T>
friend ThemeException& operator<<(ThemeException& e, T msg); friend ThemeException& operator<<(ThemeException& e, T msg);
inline void setFiles(const std::deque<boost::filesystem::path>& deque) inline void setFiles(const std::deque<std::string>& deque)
{ {
*this << "from theme \"" << deque.front().string() << "\"\n"; *this << "from theme \"" << deque.front() << "\"\n";
for(auto it = deque.cbegin() + 1; it != deque.cend(); it++) for(auto it = deque.cbegin() + 1; it != deque.cend(); it++)
*this << " (from included file \"" << (*it).string() << "\")\n"; *this << " (from included file \"" << (*it) << "\")\n";
*this << " "; *this << " ";
} }
}; };
@ -73,10 +75,10 @@ ThemeException& operator<<(ThemeException& e, T appendMsg)
struct ThemeSet struct ThemeSet
{ {
boost::filesystem::path path; std::string path;
inline std::string getName() const { return path.stem().string(); } inline std::string getName() const { return Utils::FileSystem::getStem(path); }
inline boost::filesystem::path getThemePath(const std::string& system) const { return path/system/"theme.xml"; } inline std::string getThemePath(const std::string& system) const { return path + "/" + system + "/theme.xml"; }
}; };
class ThemeData class ThemeData
@ -155,14 +157,14 @@ public:
static const std::shared_ptr<ThemeData>& getDefault(); static const std::shared_ptr<ThemeData>& getDefault();
static std::map<std::string, ThemeSet> getThemeSets(); static std::map<std::string, ThemeSet> getThemeSets();
static boost::filesystem::path getThemeFromCurrentSet(const std::string& system); static std::string getThemeFromCurrentSet(const std::string& system);
private: private:
static std::map< std::string, std::map<std::string, ElementPropertyType> > sElementMap; static std::map< std::string, std::map<std::string, ElementPropertyType> > sElementMap;
static std::vector<std::string> sSupportedFeatures; static std::vector<std::string> sSupportedFeatures;
static std::vector<std::string> sSupportedViews; static std::vector<std::string> sSupportedViews;
std::deque<boost::filesystem::path> mPaths; std::deque<std::string> mPaths;
float mVersion; float mVersion;
void parseFeatures(const pugi::xml_node& themeRoot); void parseFeatures(const pugi::xml_node& themeRoot);

View file

@ -7,6 +7,7 @@
#include "InputManager.h" #include "InputManager.h"
#include "Log.h" #include "Log.h"
#include "Renderer.h" #include "Renderer.h"
#include <algorithm>
#include <iomanip> #include <iomanip>
Window::Window() : mNormalizeNextUpdate(false), mFrameTimeElapsed(0), mFrameCountElapsed(0), mAverageDeltaTime(10), Window::Window() : mNormalizeNextUpdate(false), mFrameTimeElapsed(0), mFrameCountElapsed(0), mAverageDeltaTime(10),

View file

@ -101,8 +101,7 @@ void VideoComponent::onSizeChanged()
bool VideoComponent::setVideo(std::string path) bool VideoComponent::setVideo(std::string path)
{ {
// Convert the path into a generic format // Convert the path into a generic format
boost::filesystem::path fullPath = Utils::FileSystem::getCanonicalPath(path); std::string fullPath = Utils::FileSystem::getCanonicalPath(path);
fullPath.make_preferred().native();
// Check that it's changed // Check that it's changed
if (fullPath == mVideoPath) if (fullPath == mVideoPath)
@ -112,7 +111,7 @@ bool VideoComponent::setVideo(std::string path)
mVideoPath = fullPath; mVideoPath = fullPath;
// If the file exists then set the new video // 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 to show that we are going to attempt to play a video
return true; return true;

View file

@ -4,7 +4,6 @@
#include "components/ImageComponent.h" #include "components/ImageComponent.h"
#include "GuiComponent.h" #include "GuiComponent.h"
#include <boost/filesystem/path.hpp>
#include <string> #include <string>
class TextureResource; class TextureResource;
@ -91,14 +90,14 @@ private:
protected: protected:
unsigned mVideoWidth; unsigned mVideoWidth;
unsigned mVideoHeight; unsigned mVideoHeight;
Vector2f mTargetSize; Vector2f mTargetSize;
std::shared_ptr<TextureResource> mTexture; std::shared_ptr<TextureResource> mTexture;
float mFadeIn; float mFadeIn;
std::string mStaticImagePath; std::string mStaticImagePath;
ImageComponent mStaticImage; ImageComponent mStaticImage;
boost::filesystem::path mVideoPath; std::string mVideoPath;
boost::filesystem::path mPlayingVideoPath; std::string mPlayingVideoPath;
bool mStartDelayed; bool mStartDelayed;
unsigned mStartTime; unsigned mStartTime;
bool mIsPlaying; bool mIsPlaying;

View file

@ -6,6 +6,7 @@
#include "Renderer.h" #include "Renderer.h"
#include "Settings.h" #include "Settings.h"
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h>
#include <wait.h> #include <wait.h>
class VolumeControl class VolumeControl

View file

@ -1,6 +1,7 @@
#include "components/VideoVlcComponent.h" #include "components/VideoVlcComponent.h"
#include "resources/TextureResource.h" #include "resources/TextureResource.h"
#include "utils/StringUtil.h"
#include "PowerSaver.h" #include "PowerSaver.h"
#include "Renderer.h" #include "Renderer.h"
#include "Settings.h" #include "Settings.h"
@ -282,10 +283,9 @@ void VideoVlcComponent::startVideo()
mVideoHeight = 0; mVideoHeight = 0;
#ifdef WIN32 #ifdef WIN32
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> wton; std::string path(Utils::String::replace(mVideoPath, "/", "\\"));
std::string path = wton.to_bytes(mVideoPath.c_str());
#else #else
std::string path(mVideoPath.c_str()); std::string path(mVideoPath);
#endif #endif
// Make sure we have a video path // Make sure we have a video path
if (mVLC && (path.size() > 0)) if (mVLC && (path.size() > 0))

View file

@ -22,6 +22,21 @@ namespace Utils
{ {
namespace FileSystem 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) stringList getDirContent(const std::string& _path, const bool _recursive)
{ {
std::string path = getGenericPath(_path); std::string path = getGenericPath(_path);
@ -32,15 +47,16 @@ namespace Utils
{ {
#if defined(_WIN32) #if defined(_WIN32)
WIN32_FIND_DATA findData; WIN32_FIND_DATAW findData;
HANDLE hFind = FindFirstFile((path + "/*").c_str(), &findData); std::string wildcard = path + "/*";
HANDLE hFind = FindFirstFileW(std::wstring(wildcard.begin(), wildcard.end()).c_str(), &findData);
if(hFind != INVALID_HANDLE_VALUE) if(hFind != INVALID_HANDLE_VALUE)
{ {
// loop over all files in the directory // loop over all files in the directory
do do
{ {
std::string name(findData.cFileName); std::string name = convertFromWideString(findData.cFileName);
// ignore "." and ".." // ignore "." and ".."
if((name != ".") && (name != "..")) if((name != ".") && (name != ".."))
@ -52,7 +68,7 @@ namespace Utils
contentList.merge(getDirContent(fullName, true)); contentList.merge(getDirContent(fullName, true));
} }
} }
while(FindNextFile(hFind, &findData)); while(FindNextFileW(hFind, &findData));
FindClose(hFind); FindClose(hFind);
} }
@ -93,6 +109,31 @@ namespace Utils
} // getDirContent } // 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() std::string getHomePath()
{ {
static std::string path; static std::string path;
@ -202,20 +243,7 @@ namespace Utils
bool scan = true; bool scan = true;
while(scan) while(scan)
{ {
stringList pathList; stringList pathList = getPathList(path);
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));
path.clear(); path.clear();
scan = false; scan = false;
@ -356,12 +384,12 @@ namespace Utils
return path; return path;
// replace '.' with relativeTo // replace '.' with relativeTo
if(path[0] == '.') if((path[0] == '.') && (path[1] == '/'))
return (relativeTo + "/" + &(path[1])); return (relativeTo + &(path[1]));
// replace '~' with homePath // replace '~' with homePath
if(_allowHome && (path[0] == '~')) if(_allowHome && (path[0] == '~') && (path[1] == '/'))
return (getHomePath() + "/" + &(path[1])); return (getHomePath() + &(path[1]));
// nothing to resolve // nothing to resolve
return path; return path;
@ -376,7 +404,7 @@ namespace Utils
if(contains) if(contains)
{ {
// success // success
return ("." + path); return ("./" + path);
} }
if(_allowHome) if(_allowHome)
@ -386,7 +414,7 @@ namespace Utils
if(contains) if(contains)
{ {
// success // success
return ("~" + path); return ("~/" + path);
} }
} }

View file

@ -12,6 +12,7 @@ namespace Utils
typedef std::list<std::string> stringList; typedef std::list<std::string> stringList;
stringList getDirContent (const std::string& _path, const bool _recursive = false); stringList getDirContent (const std::string& _path, const bool _recursive = false);
stringList getPathList (const std::string& _path);
std::string getHomePath (); std::string getHomePath ();
std::string getCWDPath (); std::string getCWDPath ();
std::string getGenericPath (const std::string& _path); std::string getGenericPath (const std::string& _path);