mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-17 22:55:38 +00:00
Remove the last traces of boost::filesystem::operational, this is PR 4 of 5 in the boost::filesystem removal quest
This commit is contained in:
parent
5e031b7961
commit
403b798572
|
@ -11,7 +11,6 @@
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "SystemData.h"
|
#include "SystemData.h"
|
||||||
#include "ThemeData.h"
|
#include "ThemeData.h"
|
||||||
#include <boost/filesystem/operations.hpp>
|
|
||||||
#include <pugixml/src/pugixml.hpp>
|
#include <pugixml/src/pugixml.hpp>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
@ -884,13 +883,14 @@ std::vector<std::string> CollectionSystemManager::getSystemsFromTheme()
|
||||||
|
|
||||||
if (Utils::FileSystem::exists(themePath.generic_string()))
|
if (Utils::FileSystem::exists(themePath.generic_string()))
|
||||||
{
|
{
|
||||||
boost::filesystem::directory_iterator end_itr; // default construction yields past-the-end
|
Utils::FileSystem::stringList dirContent = Utils::FileSystem::getDirContent(themePath.generic_string());
|
||||||
for (boost::filesystem::directory_iterator itr(themePath); itr != end_itr; ++itr)
|
|
||||||
|
for (Utils::FileSystem::stringList::const_iterator it = dirContent.cbegin(); it != dirContent.cend(); ++it)
|
||||||
{
|
{
|
||||||
if (Utils::FileSystem::isDirectory(itr->path().generic_string()))
|
if (Utils::FileSystem::isDirectory(*it))
|
||||||
{
|
{
|
||||||
//... here you have a directory
|
//... here you have a directory
|
||||||
std::string folder = itr->path().string();
|
std::string folder = *it;
|
||||||
folder = folder.substr(themePath.string().size()+1);
|
folder = folder.substr(themePath.string().size()+1);
|
||||||
|
|
||||||
if(Utils::FileSystem::exists(set->second.getThemePath(folder).generic_string()))
|
if(Utils::FileSystem::exists(set->second.getThemePath(folder).generic_string()))
|
||||||
|
@ -944,13 +944,13 @@ std::vector<std::string> CollectionSystemManager::getCollectionsFromConfigFolder
|
||||||
|
|
||||||
if (Utils::FileSystem::exists(configPath.generic_string()))
|
if (Utils::FileSystem::exists(configPath.generic_string()))
|
||||||
{
|
{
|
||||||
boost::filesystem::directory_iterator end_itr; // default construction yields past-the-end
|
Utils::FileSystem::stringList dirContent = Utils::FileSystem::getDirContent(configPath.generic_string());
|
||||||
for (boost::filesystem::directory_iterator itr(configPath); itr != end_itr; ++itr)
|
for (Utils::FileSystem::stringList::const_iterator it = dirContent.cbegin(); it != dirContent.cend(); ++it)
|
||||||
{
|
{
|
||||||
if (Utils::FileSystem::isRegularFile(itr->path().generic_string()))
|
if (Utils::FileSystem::isRegularFile(*it))
|
||||||
{
|
{
|
||||||
// it's a file
|
// it's a file
|
||||||
std::string file = itr->path().string();
|
std::string file = *it;
|
||||||
std::string filename = file.substr(configPath.string().size());
|
std::string filename = file.substr(configPath.string().size());
|
||||||
|
|
||||||
// need to confirm filename matches config format
|
// need to confirm filename matches config format
|
||||||
|
@ -1019,7 +1019,7 @@ std::string getCustomCollectionConfigPath(std::string collectionName)
|
||||||
|
|
||||||
std::string getCollectionsFolder()
|
std::string getCollectionsFolder()
|
||||||
{
|
{
|
||||||
return getHomePath() + "/.emulationstation/collections/";
|
return Utils::FileSystem::getHomePath() + "/.emulationstation/collections/";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool systemSort(SystemData* sys1, SystemData* sys2)
|
bool systemSort(SystemData* sys1, SystemData* sys2)
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "SystemData.h"
|
#include "SystemData.h"
|
||||||
#include <boost/filesystem/operations.hpp>
|
|
||||||
#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 boost::filesystem::path& path, FileType type)
|
||||||
|
@ -232,7 +231,7 @@ void updateGamelist(SystemData* system)
|
||||||
|
|
||||||
boost::filesystem::path nodePath = Utils::FileSystem::resolveRelativePath(pathNode.text().get(), system->getStartPath(), true);
|
boost::filesystem::path nodePath = Utils::FileSystem::resolveRelativePath(pathNode.text().get(), system->getStartPath(), true);
|
||||||
boost::filesystem::path gamePath((*fit)->getPath());
|
boost::filesystem::path gamePath((*fit)->getPath());
|
||||||
if(nodePath == gamePath || (Utils::FileSystem::exists(nodePath.generic_string()) && Utils::FileSystem::exists(gamePath.generic_string()) && boost::filesystem::equivalent(nodePath, gamePath)))
|
if(nodePath == gamePath || (Utils::FileSystem::exists(nodePath.generic_string()) && Utils::FileSystem::exists(gamePath.generic_string()) && Utils::FileSystem::isEquivalent(nodePath.generic_string(), gamePath.generic_string())))
|
||||||
{
|
{
|
||||||
// found it
|
// found it
|
||||||
root.remove_child(fileNode);
|
root.remove_child(fileNode);
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "ThemeData.h"
|
#include "ThemeData.h"
|
||||||
#include <boost/filesystem/operations.hpp>
|
|
||||||
#include <pugixml/src/pugixml.hpp>
|
#include <pugixml/src/pugixml.hpp>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
@ -95,7 +94,7 @@ void SystemData::populateFolder(FileData* folder)
|
||||||
if(Utils::FileSystem::isSymlink(folderPath.generic_string()))
|
if(Utils::FileSystem::isSymlink(folderPath.generic_string()))
|
||||||
{
|
{
|
||||||
//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(boost::filesystem::canonical(folderPath).generic_string()) == 0)
|
if(folderStr.find(Utils::FileSystem::getCanonicalPath(folderPath.generic_string())) == 0)
|
||||||
{
|
{
|
||||||
LOG(LogWarning) << "Skipping infinitely recursive symlink \"" << folderPath << "\"";
|
LOG(LogWarning) << "Skipping infinitely recursive symlink \"" << folderPath << "\"";
|
||||||
return;
|
return;
|
||||||
|
@ -106,9 +105,10 @@ void SystemData::populateFolder(FileData* folder)
|
||||||
std::string extension;
|
std::string extension;
|
||||||
bool isGame;
|
bool isGame;
|
||||||
bool showHidden = Settings::getInstance()->getBool("ShowHiddenFiles");
|
bool showHidden = Settings::getInstance()->getBool("ShowHiddenFiles");
|
||||||
for(boost::filesystem::directory_iterator end, dir(folderPath); dir != end; ++dir)
|
Utils::FileSystem::stringList dirContent = Utils::FileSystem::getDirContent(folderPath.generic_string());
|
||||||
|
for(Utils::FileSystem::stringList::const_iterator it = dirContent.cbegin(); it != dirContent.cend(); ++it)
|
||||||
{
|
{
|
||||||
filePath = (*dir).path();
|
filePath = *it;
|
||||||
|
|
||||||
if(filePath.stem().empty())
|
if(filePath.stem().empty())
|
||||||
continue;
|
continue;
|
||||||
|
@ -268,7 +268,7 @@ bool SystemData::loadConfig()
|
||||||
if(path[0] == '~')
|
if(path[0] == '~')
|
||||||
{
|
{
|
||||||
path.erase(0, 1);
|
path.erase(0, 1);
|
||||||
path.insert(0, getHomePath());
|
path.insert(0, Utils::FileSystem::getHomePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
//create the system runtime environment data
|
//create the system runtime environment data
|
||||||
|
@ -349,7 +349,7 @@ void SystemData::deleteSystems()
|
||||||
|
|
||||||
std::string SystemData::getConfigPath(bool forWrite)
|
std::string SystemData::getConfigPath(bool forWrite)
|
||||||
{
|
{
|
||||||
boost::filesystem::path path = getHomePath() + "/.emulationstation/es_systems.cfg";
|
boost::filesystem::path path = Utils::FileSystem::getHomePath() + "/.emulationstation/es_systems.cfg";
|
||||||
if(forWrite || Utils::FileSystem::exists(path.generic_string()))
|
if(forWrite || Utils::FileSystem::exists(path.generic_string()))
|
||||||
return path.generic_string();
|
return path.generic_string();
|
||||||
|
|
||||||
|
@ -392,7 +392,7 @@ std::string SystemData::getGamelistPath(bool forWrite) const
|
||||||
if(Utils::FileSystem::exists(filePath.generic_string()))
|
if(Utils::FileSystem::exists(filePath.generic_string()))
|
||||||
return filePath.generic_string();
|
return filePath.generic_string();
|
||||||
|
|
||||||
filePath = 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(filePath.parent_path().generic_string());
|
||||||
if(forWrite || Utils::FileSystem::exists(filePath.generic_string()))
|
if(forWrite || Utils::FileSystem::exists(filePath.generic_string()))
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#include "Renderer.h"
|
#include "Renderer.h"
|
||||||
#include "Sound.h"
|
#include "Sound.h"
|
||||||
#include "SystemData.h"
|
#include "SystemData.h"
|
||||||
#include <boost/filesystem/operations.hpp>
|
|
||||||
#include <pugixml/src/pugixml.hpp>
|
#include <pugixml/src/pugixml.hpp>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
@ -418,46 +417,20 @@ void SystemScreenSaver::pickRandomCustomImage(std::string& path)
|
||||||
std::string imageDir = Settings::getInstance()->getString("SlideshowScreenSaverImageDir");
|
std::string imageDir = Settings::getInstance()->getString("SlideshowScreenSaverImageDir");
|
||||||
if ((imageDir != "") && (Utils::FileSystem::exists(imageDir)))
|
if ((imageDir != "") && (Utils::FileSystem::exists(imageDir)))
|
||||||
{
|
{
|
||||||
std::string imageFilter = Settings::getInstance()->getString("SlideshowScreenSaverImageFilter");
|
std::string imageFilter = Settings::getInstance()->getString("SlideshowScreenSaverImageFilter");
|
||||||
|
std::vector<std::string> matchingFiles;
|
||||||
|
Utils::FileSystem::stringList dirContent = Utils::FileSystem::getDirContent(imageDir, Settings::getInstance()->getBool("SlideshowScreenSaverRecurse"));
|
||||||
|
|
||||||
std::vector<std::string> matchingFiles;
|
for(Utils::FileSystem::stringList::const_iterator it = dirContent.cbegin(); it != dirContent.cend(); ++it)
|
||||||
|
|
||||||
if (Settings::getInstance()->getBool("SlideshowScreenSaverRecurse"))
|
|
||||||
{
|
{
|
||||||
boost::filesystem::recursive_directory_iterator end_iter;
|
if (Utils::FileSystem::isRegularFile(*it))
|
||||||
boost::filesystem::recursive_directory_iterator iter(imageDir);
|
|
||||||
|
|
||||||
// TODO: Figure out how to remove this duplication in the else block
|
|
||||||
for (iter; iter != end_iter; ++iter)
|
|
||||||
{
|
{
|
||||||
if (Utils::FileSystem::isRegularFile(iter->path().generic_string()))
|
// If the image filter is empty, or the file extension is in the filter string,
|
||||||
|
// add it to the matching files list
|
||||||
|
if ((imageFilter.length() <= 0) ||
|
||||||
|
(imageFilter.find(Utils::FileSystem::getExtension(*it)) != std::string::npos))
|
||||||
{
|
{
|
||||||
// If the image filter is empty, or the file extension is in the filter string,
|
matchingFiles.push_back(*it);
|
||||||
// add it to the matching files list
|
|
||||||
if ((imageFilter.length() <= 0) ||
|
|
||||||
(imageFilter.find(iter->path().extension().string()) != std::string::npos))
|
|
||||||
{
|
|
||||||
matchingFiles.push_back(iter->path().string());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
boost::filesystem::directory_iterator end_iter;
|
|
||||||
boost::filesystem::directory_iterator iter(imageDir);
|
|
||||||
|
|
||||||
for (iter; iter != end_iter; ++iter)
|
|
||||||
{
|
|
||||||
if (Utils::FileSystem::isRegularFile(iter->path().generic_string()))
|
|
||||||
{
|
|
||||||
// If the image filter is empty, or the file extension is in the filter string,
|
|
||||||
// add it to the matching files list
|
|
||||||
if ((imageFilter.length() <= 0) ||
|
|
||||||
(imageFilter.find(iter->path().extension().string()) != std::string::npos))
|
|
||||||
{
|
|
||||||
matchingFiles.push_back(iter->path().string());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,7 +167,7 @@ bool parseArgs(int argc, char* argv[])
|
||||||
bool verifyHomeFolderExists()
|
bool verifyHomeFolderExists()
|
||||||
{
|
{
|
||||||
//make sure the config directory exists
|
//make sure the config directory exists
|
||||||
std::string home = getHomePath();
|
std::string home = Utils::FileSystem::getHomePath();
|
||||||
std::string configDir = home + "/.emulationstation";
|
std::string configDir = home + "/.emulationstation";
|
||||||
if(!Utils::FileSystem::exists(configDir))
|
if(!Utils::FileSystem::exists(configDir))
|
||||||
{
|
{
|
||||||
|
|
|
@ -276,7 +276,7 @@ std::string getSaveAsPath(const ScraperSearchParams& params, const std::string&
|
||||||
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 = params.game->getPath().stem().generic_string() + "-" + suffix;
|
||||||
|
|
||||||
std::string path = getHomePath() + "/.emulationstation/downloaded_images/";
|
std::string path = Utils::FileSystem::getHomePath() + "/.emulationstation/downloaded_images/";
|
||||||
|
|
||||||
if(!Utils::FileSystem::exists(path))
|
if(!Utils::FileSystem::exists(path))
|
||||||
Utils::FileSystem::createDirectory(path);
|
Utils::FileSystem::createDirectory(path);
|
||||||
|
|
|
@ -432,14 +432,14 @@ void InputManager::doOnFinish()
|
||||||
|
|
||||||
std::string InputManager::getConfigPath()
|
std::string InputManager::getConfigPath()
|
||||||
{
|
{
|
||||||
std::string path = getHomePath();
|
std::string path = Utils::FileSystem::getHomePath();
|
||||||
path += "/.emulationstation/es_input.cfg";
|
path += "/.emulationstation/es_input.cfg";
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string InputManager::getTemporaryConfigPath()
|
std::string InputManager::getTemporaryConfigPath()
|
||||||
{
|
{
|
||||||
std::string path = getHomePath();
|
std::string path = Utils::FileSystem::getHomePath();
|
||||||
path += "/.emulationstation/es_temporaryinput.cfg";
|
path += "/.emulationstation/es_temporaryinput.cfg";
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
|
||||||
|
#include "utils/FileSystemUtil.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
@ -13,7 +14,7 @@ LogLevel Log::getReportingLevel()
|
||||||
|
|
||||||
std::string Log::getLogPath()
|
std::string Log::getLogPath()
|
||||||
{
|
{
|
||||||
std::string home = getHomePath();
|
std::string home = Utils::FileSystem::getHomePath();
|
||||||
return home + "/.emulationstation/es_log.txt";
|
return home + "/.emulationstation/es_log.txt";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,9 +99,9 @@ void Settings::setDefaults()
|
||||||
|
|
||||||
mIntMap["ScreenSaverSwapImageTimeout"] = 10000;
|
mIntMap["ScreenSaverSwapImageTimeout"] = 10000;
|
||||||
mBoolMap["SlideshowScreenSaverStretch"] = false;
|
mBoolMap["SlideshowScreenSaverStretch"] = false;
|
||||||
mStringMap["SlideshowScreenSaverBackgroundAudioFile"] = getHomePath() + "/.emulationstation/slideshow/audio/slideshow_bg.wav";
|
mStringMap["SlideshowScreenSaverBackgroundAudioFile"] = Utils::FileSystem::getHomePath() + "/.emulationstation/slideshow/audio/slideshow_bg.wav";
|
||||||
mBoolMap["SlideshowScreenSaverCustomImageSource"] = false;
|
mBoolMap["SlideshowScreenSaverCustomImageSource"] = false;
|
||||||
mStringMap["SlideshowScreenSaverImageDir"] = getHomePath() + "/.emulationstation/slideshow/image";
|
mStringMap["SlideshowScreenSaverImageDir"] = Utils::FileSystem::getHomePath() + "/.emulationstation/slideshow/image";
|
||||||
mStringMap["SlideshowScreenSaverImageFilter"] = ".png,.jpg";
|
mStringMap["SlideshowScreenSaverImageFilter"] = ".png,.jpg";
|
||||||
mBoolMap["SlideshowScreenSaverRecurse"] = false;
|
mBoolMap["SlideshowScreenSaverRecurse"] = false;
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ void saveMap(pugi::xml_document& doc, std::map<K, V>& map, const char* type)
|
||||||
void Settings::saveFile()
|
void Settings::saveFile()
|
||||||
{
|
{
|
||||||
LOG(LogDebug) << "Settings::saveFile() : Saving Settings to file.";
|
LOG(LogDebug) << "Settings::saveFile() : Saving Settings to file.";
|
||||||
const std::string path = getHomePath() + "/.emulationstation/es_settings.cfg";
|
const std::string path = Utils::FileSystem::getHomePath() + "/.emulationstation/es_settings.cfg";
|
||||||
|
|
||||||
pugi::xml_document doc;
|
pugi::xml_document doc;
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ void Settings::saveFile()
|
||||||
|
|
||||||
void Settings::loadFile()
|
void Settings::loadFile()
|
||||||
{
|
{
|
||||||
const std::string path = getHomePath() + "/.emulationstation/es_settings.cfg";
|
const std::string path = Utils::FileSystem::getHomePath() + "/.emulationstation/es_settings.cfg";
|
||||||
|
|
||||||
if(!Utils::FileSystem::exists(path))
|
if(!Utils::FileSystem::exists(path))
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include <boost/filesystem/operations.hpp>
|
|
||||||
#include <pugixml/src/pugixml.hpp>
|
#include <pugixml/src/pugixml.hpp>
|
||||||
|
|
||||||
std::vector<std::string> ThemeData::sSupportedViews { { "system" }, { "basic" }, { "detailed" }, { "video" } };
|
std::vector<std::string> ThemeData::sSupportedViews { { "system" }, { "basic" }, { "detailed" }, { "video" } };
|
||||||
|
@ -163,7 +162,7 @@ std::string resolvePath(const char* in, const boost::filesystem::path& relative)
|
||||||
// some directories could theoretically start with ~ or .
|
// some directories could theoretically start with ~ or .
|
||||||
if(*path.begin() == "~")
|
if(*path.begin() == "~")
|
||||||
{
|
{
|
||||||
path = getHomePath() + (in + 1);
|
path = Utils::FileSystem::getHomePath() + (in + 1);
|
||||||
}else if(*path.begin() == ".")
|
}else if(*path.begin() == ".")
|
||||||
{
|
{
|
||||||
path = relPath / (in + 1);
|
path = relPath / (in + 1);
|
||||||
|
@ -484,7 +483,7 @@ const std::shared_ptr<ThemeData>& ThemeData::getDefault()
|
||||||
{
|
{
|
||||||
theme = std::shared_ptr<ThemeData>(new ThemeData());
|
theme = std::shared_ptr<ThemeData>(new ThemeData());
|
||||||
|
|
||||||
const std::string path = getHomePath() + "/.emulationstation/es_theme_default.xml";
|
const std::string path = Utils::FileSystem::getHomePath() + "/.emulationstation/es_theme_default.xml";
|
||||||
if(Utils::FileSystem::exists(path))
|
if(Utils::FileSystem::exists(path))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -538,19 +537,19 @@ std::map<std::string, ThemeSet> ThemeData::getThemeSets()
|
||||||
static const size_t pathCount = 2;
|
static const size_t pathCount = 2;
|
||||||
boost::filesystem::path paths[pathCount] = {
|
boost::filesystem::path paths[pathCount] = {
|
||||||
"/etc/emulationstation/themes",
|
"/etc/emulationstation/themes",
|
||||||
getHomePath() + "/.emulationstation/themes"
|
Utils::FileSystem::getHomePath() + "/.emulationstation/themes"
|
||||||
};
|
};
|
||||||
|
|
||||||
boost::filesystem::directory_iterator end;
|
|
||||||
|
|
||||||
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].generic_string()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for(boost::filesystem::directory_iterator it(paths[i]); it != end; ++it)
|
Utils::FileSystem::stringList dirContent = Utils::FileSystem::getDirContent(paths[i].generic_string());
|
||||||
|
|
||||||
|
for(Utils::FileSystem::stringList::const_iterator it = dirContent.cbegin(); it != dirContent.cend(); ++it)
|
||||||
{
|
{
|
||||||
if(Utils::FileSystem::isDirectory((*it).path().generic_string()))
|
if(Utils::FileSystem::isDirectory(*it))
|
||||||
{
|
{
|
||||||
ThemeSet set = {*it};
|
ThemeSet set = {*it};
|
||||||
sets[set.getName()] = set;
|
sets[set.getName()] = set;
|
||||||
|
|
|
@ -16,7 +16,7 @@ std::string getTitlePath() {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getTitleFolder() {
|
std::string getTitleFolder() {
|
||||||
std::string home = getHomePath();
|
std::string home = Utils::FileSystem::getHomePath();
|
||||||
return home + "/.emulationstation/tmp/";
|
return home + "/.emulationstation/tmp/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,44 +1,13 @@
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
||||||
#include <boost/filesystem/path.hpp>
|
|
||||||
#include <SDL_events.h>
|
#include <SDL_events.h>
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <codecvt>
|
#include <codecvt>
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
std::string getHomePath()
|
|
||||||
{
|
|
||||||
std::string homePath;
|
|
||||||
|
|
||||||
// this should give you something like "/home/YOUR_USERNAME" on Linux and "C:\Users\YOUR_USERNAME\" on Windows
|
|
||||||
const char * envHome = getenv("HOME");
|
|
||||||
if(envHome != nullptr)
|
|
||||||
{
|
|
||||||
homePath = envHome;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
// but does not seem to work for Windows XP or Vista, so try something else
|
|
||||||
if (homePath.empty()) {
|
|
||||||
const char * envDir = getenv("HOMEDRIVE");
|
|
||||||
const char * envPath = getenv("HOMEPATH");
|
|
||||||
if (envDir != nullptr && envPath != nullptr) {
|
|
||||||
homePath = envDir;
|
|
||||||
homePath += envPath;
|
|
||||||
|
|
||||||
for(unsigned int i = 0; i < homePath.length(); i++)
|
|
||||||
if(homePath[i] == '\\')
|
|
||||||
homePath[i] = '/';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// convert path to generic directory seperators
|
|
||||||
boost::filesystem::path genericPath(homePath);
|
|
||||||
return genericPath.generic_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
int runShutdownCommand()
|
int runShutdownCommand()
|
||||||
{
|
{
|
||||||
#ifdef WIN32 // windows
|
#ifdef WIN32 // windows
|
||||||
|
|
|
@ -21,9 +21,6 @@
|
||||||
#define GLHEADER <SDL_opengl.h>
|
#define GLHEADER <SDL_opengl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string getHomePath();
|
|
||||||
|
|
||||||
|
|
||||||
int runShutdownCommand(); // shut down the system (returns 0 if successful)
|
int runShutdownCommand(); // shut down the system (returns 0 if successful)
|
||||||
int runRestartCommand(); // restart the system (returns 0 if successful)
|
int runRestartCommand(); // restart the system (returns 0 if successful)
|
||||||
int runSystemCommand(const std::string& cmd_utf8); // run a utf-8 encoded in the shell (requires wstring conversion on Windows)
|
int runSystemCommand(const std::string& cmd_utf8); // run a utf-8 encoded in the shell (requires wstring conversion on Windows)
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace Utils
|
||||||
{
|
{
|
||||||
namespace FileSystem
|
namespace FileSystem
|
||||||
{
|
{
|
||||||
stringList getDirContent(const std::string& _path)
|
stringList getDirContent(const std::string& _path, const bool _recursive)
|
||||||
{
|
{
|
||||||
std::string path = getGenericPath(_path);
|
std::string path = getGenericPath(_path);
|
||||||
stringList contentList;
|
stringList contentList;
|
||||||
|
@ -44,7 +44,13 @@ namespace Utils
|
||||||
|
|
||||||
// ignore "." and ".."
|
// ignore "." and ".."
|
||||||
if((name != ".") && (name != ".."))
|
if((name != ".") && (name != ".."))
|
||||||
contentList.push_back(name);
|
{
|
||||||
|
std::string fullName(path + "/" + name);
|
||||||
|
contentList.push_back(fullName);
|
||||||
|
|
||||||
|
if(_recursive && isDirectory(fullName))
|
||||||
|
contentList.merge(getDirContent(fullName, true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
while(FindNextFile(hFind, &findData));
|
while(FindNextFile(hFind, &findData));
|
||||||
|
|
||||||
|
@ -64,7 +70,13 @@ namespace Utils
|
||||||
|
|
||||||
// ignore "." and ".."
|
// ignore "." and ".."
|
||||||
if((name != ".") && (name != ".."))
|
if((name != ".") && (name != ".."))
|
||||||
contentList.push_back(name);
|
{
|
||||||
|
std::string fullName(path + "/" + name);
|
||||||
|
contentList.push_back(fullName);
|
||||||
|
|
||||||
|
if(_recursive && isDirectory(fullName))
|
||||||
|
contentList.merge(getDirContent(fullName, true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace Utils
|
||||||
{
|
{
|
||||||
typedef std::list<std::string> stringList;
|
typedef std::list<std::string> stringList;
|
||||||
|
|
||||||
stringList getDirContent (const std::string& _path);
|
stringList getDirContent (const std::string& _path, const bool _recursive = false);
|
||||||
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);
|
||||||
|
|
Loading…
Reference in a new issue