mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 22:25:38 +00:00
Update and rename some Utils::FileSystem functions
Replace boost::filesystem::is_directory with Utils::FileSystem::isDirectory Replace boost::filesystem::is_regular_file with Utils::FileSystem::isRegularFile Replace boost::filesystem::is_symlink with Utils::FileSystem::isSymlink Replace boost::filesystem::exists with Utils::FileSystem::exists Replace boost::filesystem::create_directory with Utils::FileSystem::createDirectory Replace boost::filesystem::remove with Utils::FileSystem::removeFile
This commit is contained in:
parent
96a0fa3a14
commit
c1f8e7294c
|
@ -1,6 +1,7 @@
|
|||
#include "CollectionSystemManager.h"
|
||||
|
||||
#include "guis/GuiInfoPopup.h"
|
||||
#include "utils/FileSystemUtil.h"
|
||||
#include "utils/StringUtil.h"
|
||||
#include "views/gamelist/IGameListView.h"
|
||||
#include "views/ViewController.h"
|
||||
|
@ -50,8 +51,8 @@ CollectionSystemManager::CollectionSystemManager(Window* window) : mWindow(windo
|
|||
mCollectionEnvData->mPlatformIds = allPlatformIds;
|
||||
|
||||
std::string path = getCollectionsFolder();
|
||||
if(!boost::filesystem::exists(path))
|
||||
boost::filesystem::create_directory(path);
|
||||
if(!Utils::FileSystem::exists(path))
|
||||
Utils::FileSystem::createDirectory(path);
|
||||
|
||||
mIsEditingCustom = false;
|
||||
mEditingCollection = "Favorites";
|
||||
|
@ -332,7 +333,7 @@ bool CollectionSystemManager::isThemeCustomCollectionCompatible(std::vector<std:
|
|||
if(set != themeSets.cend())
|
||||
{
|
||||
std::string defaultThemeFilePath = set->second.path.string() + "/theme.xml";
|
||||
if (boost::filesystem::exists(defaultThemeFilePath))
|
||||
if (Utils::FileSystem::exists(defaultThemeFilePath))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -722,7 +723,7 @@ void CollectionSystemManager::populateCustomCollection(CollectionSystemData* sys
|
|||
CollectionSystemDecl sysDecl = sysData->decl;
|
||||
std::string path = getCustomCollectionConfigPath(newSys->getName());
|
||||
|
||||
if(!boost::filesystem::exists(path))
|
||||
if(!Utils::FileSystem::exists(path))
|
||||
{
|
||||
LOG(LogInfo) << "Couldn't find custom collection config file at " << path;
|
||||
return;
|
||||
|
@ -829,7 +830,7 @@ std::vector<std::string> CollectionSystemManager::getSystemsFromConfig()
|
|||
std::vector<std::string> systems;
|
||||
std::string path = SystemData::getConfigPath(false);
|
||||
|
||||
if(!boost::filesystem::exists(path))
|
||||
if(!Utils::FileSystem::exists(path))
|
||||
{
|
||||
return systems;
|
||||
}
|
||||
|
@ -882,18 +883,18 @@ std::vector<std::string> CollectionSystemManager::getSystemsFromTheme()
|
|||
|
||||
boost::filesystem::path themePath = set->second.path;
|
||||
|
||||
if (boost::filesystem::exists(themePath))
|
||||
if (Utils::FileSystem::exists(themePath.generic_string()))
|
||||
{
|
||||
boost::filesystem::directory_iterator end_itr; // default construction yields past-the-end
|
||||
for (boost::filesystem::directory_iterator itr(themePath); itr != end_itr; ++itr)
|
||||
{
|
||||
if (boost::filesystem::is_directory(itr->status()))
|
||||
if (Utils::FileSystem::isDirectory(itr->path().generic_string()))
|
||||
{
|
||||
//... here you have a directory
|
||||
std::string folder = itr->path().string();
|
||||
folder = folder.substr(themePath.string().size()+1);
|
||||
|
||||
if(boost::filesystem::exists(set->second.getThemePath(folder)))
|
||||
if(Utils::FileSystem::exists(set->second.getThemePath(folder).generic_string()))
|
||||
{
|
||||
systems.push_back(folder);
|
||||
}
|
||||
|
@ -942,12 +943,12 @@ std::vector<std::string> CollectionSystemManager::getCollectionsFromConfigFolder
|
|||
std::vector<std::string> systems;
|
||||
boost::filesystem::path configPath = getCollectionsFolder();
|
||||
|
||||
if (boost::filesystem::exists(configPath))
|
||||
if (Utils::FileSystem::exists(configPath.generic_string()))
|
||||
{
|
||||
boost::filesystem::directory_iterator end_itr; // default construction yields past-the-end
|
||||
for (boost::filesystem::directory_iterator itr(configPath); itr != end_itr; ++itr)
|
||||
{
|
||||
if (boost::filesystem::is_regular_file(itr->status()))
|
||||
if (Utils::FileSystem::isRegularFile(itr->path().generic_string()))
|
||||
{
|
||||
// it's a file
|
||||
std::string file = itr->path().string();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "FileData.h"
|
||||
|
||||
#include "utils/FileSystemUtil.h"
|
||||
#include "utils/StringUtil.h"
|
||||
#include "utils/TimeUtil.h"
|
||||
#include "AudioManager.h"
|
||||
|
@ -12,7 +13,6 @@
|
|||
#include "Util.h"
|
||||
#include "VolumeControl.h"
|
||||
#include "Window.h"
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
|
||||
FileData::FileData(FileType type, const boost::filesystem::path& 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!
|
||||
|
@ -66,7 +66,7 @@ const std::string FileData::getThumbnailPath() const
|
|||
if(thumbnail.empty())
|
||||
{
|
||||
std::string path = mEnvData->mStartPath + "/images/" + getDisplayName() + "-image" + extList[i];
|
||||
if(boost::filesystem::exists(path))
|
||||
if(Utils::FileSystem::exists(path))
|
||||
thumbnail = path;
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ const std::string FileData::getVideoPath() const
|
|||
if(video.empty())
|
||||
{
|
||||
std::string path = mEnvData->mStartPath + "/images/" + getDisplayName() + "-video.mp4";
|
||||
if(boost::filesystem::exists(path))
|
||||
if(Utils::FileSystem::exists(path))
|
||||
video = path;
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ const std::string FileData::getMarqueePath() const
|
|||
if(marquee.empty())
|
||||
{
|
||||
std::string path = mEnvData->mStartPath + "/images/" + getDisplayName() + "-marquee" + extList[i];
|
||||
if(boost::filesystem::exists(path))
|
||||
if(Utils::FileSystem::exists(path))
|
||||
marquee = path;
|
||||
}
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ const std::string FileData::getImagePath() const
|
|||
if(image.empty())
|
||||
{
|
||||
std::string path = mEnvData->mStartPath + "/images/" + getDisplayName() + "-image" + extList[i];
|
||||
if(boost::filesystem::exists(path))
|
||||
if(Utils::FileSystem::exists(path))
|
||||
image = path;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "Gamelist.h"
|
||||
|
||||
#include "utils/FileSystemUtil.h"
|
||||
#include "FileData.h"
|
||||
#include "FileFilterIndex.h"
|
||||
#include "Log.h"
|
||||
|
@ -87,7 +88,7 @@ void parseGamelist(SystemData* system)
|
|||
bool trustGamelist = Settings::getInstance()->getBool("ParseGamelistOnly");
|
||||
std::string xmlpath = system->getGamelistPath(false);
|
||||
|
||||
if(!boost::filesystem::exists(xmlpath))
|
||||
if(!Utils::FileSystem::exists(xmlpath))
|
||||
return;
|
||||
|
||||
LOG(LogInfo) << "Parsing XML file \"" << xmlpath << "\"...";
|
||||
|
@ -120,7 +121,7 @@ void parseGamelist(SystemData* system)
|
|||
{
|
||||
boost::filesystem::path path = resolvePath(fileNode.child("path").text().get(), relativeTo, false);
|
||||
|
||||
if(!trustGamelist && !boost::filesystem::exists(path))
|
||||
if(!trustGamelist && !Utils::FileSystem::exists(path.generic_string()))
|
||||
{
|
||||
LOG(LogWarning) << "File \"" << path << "\" does not exist! Ignoring.";
|
||||
continue;
|
||||
|
@ -183,7 +184,7 @@ void updateGamelist(SystemData* system)
|
|||
pugi::xml_node root;
|
||||
std::string xmlReadPath = system->getGamelistPath(false);
|
||||
|
||||
if(boost::filesystem::exists(xmlReadPath))
|
||||
if(Utils::FileSystem::exists(xmlReadPath))
|
||||
{
|
||||
//parse an existing file first
|
||||
pugi::xml_parse_result result = doc.load_file(xmlReadPath.c_str());
|
||||
|
@ -241,7 +242,7 @@ void updateGamelist(SystemData* system)
|
|||
|
||||
boost::filesystem::path nodePath = resolvePath(pathNode.text().get(), system->getStartPath(), true);
|
||||
boost::filesystem::path gamePath((*fit)->getPath());
|
||||
if(nodePath == gamePath || (boost::filesystem::exists(nodePath) && boost::filesystem::exists(gamePath) && boost::filesystem::equivalent(nodePath, gamePath)))
|
||||
if(nodePath == gamePath || (Utils::FileSystem::exists(nodePath.generic_string()) && Utils::FileSystem::exists(gamePath.generic_string()) && boost::filesystem::equivalent(nodePath, gamePath)))
|
||||
{
|
||||
// found it
|
||||
root.remove_child(fileNode);
|
||||
|
@ -259,7 +260,7 @@ 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));
|
||||
boost::filesystem::create_directories(xmlWritePath.parent_path());
|
||||
Utils::FileSystem::createDirectory(xmlWritePath.parent_path().generic_string());
|
||||
|
||||
LOG(LogInfo) << "Added/Updated " << numUpdated << " entities in '" << xmlReadPath << "'";
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "SystemData.h"
|
||||
|
||||
#include "utils/FileSystemUtil.h"
|
||||
#include "CollectionSystemManager.h"
|
||||
#include "FileFilterIndex.h"
|
||||
#include "FileSorts.h"
|
||||
|
@ -82,7 +83,7 @@ bool isHidden(const boost::filesystem::path &filePath)
|
|||
void SystemData::populateFolder(FileData* folder)
|
||||
{
|
||||
const boost::filesystem::path& folderPath = folder->getPath();
|
||||
if(!boost::filesystem::is_directory(folderPath))
|
||||
if(!Utils::FileSystem::isDirectory(folderPath.generic_string()))
|
||||
{
|
||||
LOG(LogWarning) << "Error - folder with path \"" << folderPath << "\" is not a directory!";
|
||||
return;
|
||||
|
@ -91,7 +92,7 @@ void SystemData::populateFolder(FileData* folder)
|
|||
const std::string folderStr = folderPath.generic_string();
|
||||
|
||||
//make sure that this isn't a symlink to a thing we already have
|
||||
if(boost::filesystem::is_symlink(folderPath))
|
||||
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(folderStr.find(boost::filesystem::canonical(folderPath).generic_string()) == 0)
|
||||
|
@ -132,7 +133,7 @@ void SystemData::populateFolder(FileData* folder)
|
|||
}
|
||||
|
||||
//add directories that also do not match an extension as folders
|
||||
if(!isGame && boost::filesystem::is_directory(filePath))
|
||||
if(!isGame && Utils::FileSystem::isDirectory(filePath.generic_string()))
|
||||
{
|
||||
FileData* newFolder = new FileData(FOLDER, filePath.generic_string(), mEnvData, this);
|
||||
populateFolder(newFolder);
|
||||
|
@ -186,7 +187,7 @@ bool SystemData::loadConfig()
|
|||
|
||||
LOG(LogInfo) << "Loading system config file " << path << "...";
|
||||
|
||||
if(!boost::filesystem::exists(path))
|
||||
if(!Utils::FileSystem::exists(path))
|
||||
{
|
||||
LOG(LogError) << "es_systems.cfg file does not exist!";
|
||||
writeExampleConfig(getConfigPath(true));
|
||||
|
@ -349,7 +350,7 @@ void SystemData::deleteSystems()
|
|||
std::string SystemData::getConfigPath(bool forWrite)
|
||||
{
|
||||
boost::filesystem::path path = getHomePath() + "/.emulationstation/es_systems.cfg";
|
||||
if(forWrite || boost::filesystem::exists(path))
|
||||
if(forWrite || Utils::FileSystem::exists(path.generic_string()))
|
||||
return path.generic_string();
|
||||
|
||||
return "/etc/emulationstation/es_systems.cfg";
|
||||
|
@ -388,13 +389,13 @@ std::string SystemData::getGamelistPath(bool forWrite) const
|
|||
boost::filesystem::path filePath;
|
||||
|
||||
filePath = mRootFolder->getPath() / "gamelist.xml";
|
||||
if(boost::filesystem::exists(filePath))
|
||||
if(Utils::FileSystem::exists(filePath.generic_string()))
|
||||
return filePath.generic_string();
|
||||
|
||||
filePath = 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
|
||||
boost::filesystem::create_directories(filePath.parent_path());
|
||||
if(forWrite || boost::filesystem::exists(filePath))
|
||||
Utils::FileSystem::createDirectory(filePath.parent_path().generic_string());
|
||||
if(forWrite || Utils::FileSystem::exists(filePath.generic_string()))
|
||||
return filePath.generic_string();
|
||||
|
||||
return "/etc/emulationstation/gamelists/" + mName + "/gamelist.xml";
|
||||
|
@ -409,13 +410,13 @@ std::string SystemData::getThemePath() const
|
|||
|
||||
// first, check game folder
|
||||
boost::filesystem::path localThemePath = mRootFolder->getPath() / "theme.xml";
|
||||
if(boost::filesystem::exists(localThemePath))
|
||||
if(Utils::FileSystem::exists(localThemePath.generic_string()))
|
||||
return localThemePath.generic_string();
|
||||
|
||||
// not in game folder, try system theme in theme sets
|
||||
localThemePath = ThemeData::getThemeFromCurrentSet(mThemeFolder);
|
||||
|
||||
if (boost::filesystem::exists(localThemePath))
|
||||
if (Utils::FileSystem::exists(localThemePath.generic_string()))
|
||||
return localThemePath.generic_string();
|
||||
|
||||
// not system theme, try default system theme in theme set
|
||||
|
@ -426,7 +427,7 @@ std::string SystemData::getThemePath() const
|
|||
|
||||
bool SystemData::hasGamelist() const
|
||||
{
|
||||
return (boost::filesystem::exists(getGamelistPath(false)));
|
||||
return (Utils::FileSystem::exists(getGamelistPath(false)));
|
||||
}
|
||||
|
||||
unsigned int SystemData::getGameCount() const
|
||||
|
@ -488,7 +489,7 @@ void SystemData::loadTheme()
|
|||
|
||||
std::string path = getThemePath();
|
||||
|
||||
if(!boost::filesystem::exists(path)) // no theme available for this platform
|
||||
if(!Utils::FileSystem::exists(path)) // no theme available for this platform
|
||||
return;
|
||||
|
||||
try
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "components/VideoPlayerComponent.h"
|
||||
#endif
|
||||
#include "components/VideoVlcComponent.h"
|
||||
#include "utils/FileSystemUtil.h"
|
||||
#include "views/gamelist/IGameListView.h"
|
||||
#include "views/ViewController.h"
|
||||
#include "FileData.h"
|
||||
|
@ -38,8 +39,8 @@ SystemScreenSaver::SystemScreenSaver(Window* window) :
|
|||
{
|
||||
mWindow->setScreenSaver(this);
|
||||
std::string path = getTitleFolder();
|
||||
if(!boost::filesystem::exists(path))
|
||||
boost::filesystem::create_directory(path);
|
||||
if(!Utils::FileSystem::exists(path))
|
||||
Utils::FileSystem::createDirectory(path);
|
||||
srand((unsigned int)time(NULL));
|
||||
mVideoChangeTime = 30000;
|
||||
}
|
||||
|
@ -81,13 +82,13 @@ void SystemScreenSaver::startScreenSaver()
|
|||
pickRandomVideo(path);
|
||||
|
||||
int retry = 200;
|
||||
while(retry > 0 && ((path.empty() || !boost::filesystem::exists(path)) || mCurrentGame == NULL))
|
||||
while(retry > 0 && ((path.empty() || !Utils::FileSystem::exists(path)) || mCurrentGame == NULL))
|
||||
{
|
||||
retry--;
|
||||
pickRandomVideo(path);
|
||||
}
|
||||
|
||||
if (!path.empty() && boost::filesystem::exists(path))
|
||||
if (!path.empty() && Utils::FileSystem::exists(path))
|
||||
{
|
||||
#ifdef _RPI_
|
||||
// Create the correct type of video component
|
||||
|
@ -164,7 +165,7 @@ void SystemScreenSaver::startScreenSaver()
|
|||
std::string bg_audio_file = Settings::getInstance()->getString("SlideshowScreenSaverBackgroundAudioFile");
|
||||
if ((!mBackgroundAudio) && (bg_audio_file != ""))
|
||||
{
|
||||
if (boost::filesystem::exists(bg_audio_file))
|
||||
if (Utils::FileSystem::exists(bg_audio_file))
|
||||
{
|
||||
// paused PS so that the background audio keeps playing
|
||||
PowerSaver::pause();
|
||||
|
@ -269,7 +270,7 @@ unsigned long SystemScreenSaver::countGameListNodes(const char *nodeName)
|
|||
pugi::xml_node root;
|
||||
std::string xmlReadPath = (*it)->getGamelistPath(false);
|
||||
|
||||
if(boost::filesystem::exists(xmlReadPath))
|
||||
if(Utils::FileSystem::exists(xmlReadPath))
|
||||
{
|
||||
pugi::xml_parse_result result = doc.load_file(xmlReadPath.c_str());
|
||||
if (!result)
|
||||
|
@ -321,7 +322,7 @@ void SystemScreenSaver::pickGameListNode(unsigned long index, const char *nodeNa
|
|||
|
||||
std::string xmlReadPath = (*it)->getGamelistPath(false);
|
||||
|
||||
if(boost::filesystem::exists(xmlReadPath))
|
||||
if(Utils::FileSystem::exists(xmlReadPath))
|
||||
{
|
||||
pugi::xml_parse_result result = doc.load_file(xmlReadPath.c_str());
|
||||
if (!result)
|
||||
|
@ -416,7 +417,7 @@ void SystemScreenSaver::pickRandomGameListImage(std::string& path)
|
|||
void SystemScreenSaver::pickRandomCustomImage(std::string& path)
|
||||
{
|
||||
std::string imageDir = Settings::getInstance()->getString("SlideshowScreenSaverImageDir");
|
||||
if ((imageDir != "") && (boost::filesystem::exists(imageDir)))
|
||||
if ((imageDir != "") && (Utils::FileSystem::exists(imageDir)))
|
||||
{
|
||||
std::string imageFilter = Settings::getInstance()->getString("SlideshowScreenSaverImageFilter");
|
||||
|
||||
|
@ -430,7 +431,7 @@ void SystemScreenSaver::pickRandomCustomImage(std::string& path)
|
|||
// TODO: Figure out how to remove this duplication in the else block
|
||||
for (iter; iter != end_iter; ++iter)
|
||||
{
|
||||
if (boost::filesystem::is_regular_file(iter->status()))
|
||||
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
|
||||
|
@ -449,7 +450,7 @@ void SystemScreenSaver::pickRandomCustomImage(std::string& path)
|
|||
|
||||
for (iter; iter != end_iter; ++iter)
|
||||
{
|
||||
if (boost::filesystem::is_regular_file(iter->status()))
|
||||
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
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "guis/GuiDetectDevice.h"
|
||||
#include "guis/GuiMsgBox.h"
|
||||
#include "utils/FileSystemUtil.h"
|
||||
#include "views/ViewController.h"
|
||||
#include "CollectionSystemManager.h"
|
||||
#include "EmulationStation.h"
|
||||
|
@ -14,7 +15,6 @@
|
|||
#include "Settings.h"
|
||||
#include "SystemData.h"
|
||||
#include "SystemScreenSaver.h"
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <SDL_events.h>
|
||||
#include <SDL_main.h>
|
||||
#include <SDL_timer.h>
|
||||
|
@ -169,11 +169,11 @@ bool verifyHomeFolderExists()
|
|||
//make sure the config directory exists
|
||||
std::string home = getHomePath();
|
||||
std::string configDir = home + "/.emulationstation";
|
||||
if(!boost::filesystem::exists(configDir))
|
||||
if(!Utils::FileSystem::exists(configDir))
|
||||
{
|
||||
std::cout << "Creating config directory \"" << configDir << "\"\n";
|
||||
boost::filesystem::create_directory(configDir);
|
||||
if(!boost::filesystem::exists(configDir))
|
||||
Utils::FileSystem::createDirectory(configDir);
|
||||
if(!Utils::FileSystem::exists(configDir))
|
||||
{
|
||||
std::cerr << "Config directory could not be created!\n";
|
||||
return false;
|
||||
|
@ -335,7 +335,7 @@ int main(int argc, char* argv[])
|
|||
//choose which GUI to open depending on if an input configuration already exists
|
||||
if(errorMsg == NULL)
|
||||
{
|
||||
if(boost::filesystem::exists(InputManager::getConfigPath()) && InputManager::getInstance()->getNumConfiguredDevices() > 0)
|
||||
if(Utils::FileSystem::exists(InputManager::getConfigPath()) && InputManager::getInstance()->getNumConfiguredDevices() > 0)
|
||||
{
|
||||
ViewController::get()->goToStart();
|
||||
}else{
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#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 <boost/filesystem/operations.hpp>
|
||||
#include <FreeImage.h>
|
||||
#include <fstream>
|
||||
|
||||
|
@ -278,13 +278,13 @@ std::string getSaveAsPath(const ScraperSearchParams& params, const std::string&
|
|||
|
||||
std::string path = getHomePath() + "/.emulationstation/downloaded_images/";
|
||||
|
||||
if(!boost::filesystem::exists(path))
|
||||
boost::filesystem::create_directory(path);
|
||||
if(!Utils::FileSystem::exists(path))
|
||||
Utils::FileSystem::createDirectory(path);
|
||||
|
||||
path += subdirectory + "/";
|
||||
|
||||
if(!boost::filesystem::exists(path))
|
||||
boost::filesystem::create_directory(path);
|
||||
if(!Utils::FileSystem::exists(path))
|
||||
Utils::FileSystem::createDirectory(path);
|
||||
|
||||
size_t dot = url.find_last_of('.');
|
||||
std::string ext;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#include "views/gamelist/BasicGameListView.h"
|
||||
|
||||
#include "utils/FileSystemUtil.h"
|
||||
#include "views/UIModeController.h"
|
||||
#include "views/ViewController.h"
|
||||
#include "CollectionSystemManager.h"
|
||||
#include "Settings.h"
|
||||
#include "SystemData.h"
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
|
||||
BasicGameListView::BasicGameListView(Window* window, FileData* root)
|
||||
: ISimpleGameListView(window, root), mList(window)
|
||||
|
@ -105,7 +105,7 @@ void BasicGameListView::launch(FileData* game)
|
|||
void BasicGameListView::remove(FileData *game, bool deleteFile)
|
||||
{
|
||||
if (deleteFile)
|
||||
boost::filesystem::remove(game->getPath()); // actually delete the file on the filesystem
|
||||
Utils::FileSystem::removeFile(game->getPath().generic_string()); // actually delete the file on the filesystem
|
||||
FileData* parent = game->getParent();
|
||||
if (getCursor() == game) // Select next element in list, or prev if none
|
||||
{
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
#include "components/VideoPlayerComponent.h"
|
||||
#endif
|
||||
#include "components/VideoVlcComponent.h"
|
||||
#include "utils/FileSystemUtil.h"
|
||||
#include "views/ViewController.h"
|
||||
#ifdef _RPI_
|
||||
#include "Settings.h"
|
||||
#endif
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
|
||||
VideoGameListView::VideoGameListView(Window* window, FileData* root) :
|
||||
BasicGameListView(window, root),
|
||||
|
@ -224,7 +224,7 @@ void VideoGameListView::updateInfoPanel()
|
|||
{
|
||||
FileData* file = (mList.size() == 0 || mList.isScrolling()) ? NULL : mList.getSelected();
|
||||
|
||||
boost::filesystem::remove(getTitlePath().c_str());
|
||||
Utils::FileSystem::removeFile(getTitlePath());
|
||||
|
||||
bool fadingOut;
|
||||
if(file == NULL)
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include "HttpReq.h"
|
||||
|
||||
#include "utils/FileSystemUtil.h"
|
||||
#include "Log.h"
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <assert.h>
|
||||
|
||||
CURLM* HttpReq::s_multi_handle = curl_multi_init();
|
||||
|
||||
|
@ -32,7 +33,7 @@ std::string HttpReq::urlEncode(const std::string &s)
|
|||
bool HttpReq::isUrl(const std::string& str)
|
||||
{
|
||||
//the worst guess
|
||||
return (!str.empty() && !boost::filesystem::exists(str) &&
|
||||
return (!str.empty() && !Utils::FileSystem::exists(str) &&
|
||||
(str.find("http://") != std::string::npos || str.find("https://") != std::string::npos || str.find("www.") != std::string::npos));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include "InputManager.h"
|
||||
|
||||
#include "utils/FileSystemUtil.h"
|
||||
#include "CECInput.h"
|
||||
#include "Log.h"
|
||||
#include "platform.h"
|
||||
#include "Window.h"
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <pugixml/src/pugixml.hpp>
|
||||
#include <SDL.h>
|
||||
#include <iostream>
|
||||
|
@ -278,7 +278,7 @@ bool InputManager::parseEvent(const SDL_Event& ev, Window* window)
|
|||
bool InputManager::loadInputConfig(InputConfig* config)
|
||||
{
|
||||
std::string path = getConfigPath();
|
||||
if(!boost::filesystem::exists(path))
|
||||
if(!Utils::FileSystem::exists(path))
|
||||
return false;
|
||||
|
||||
pugi::xml_document doc;
|
||||
|
@ -333,7 +333,7 @@ void InputManager::writeDeviceConfig(InputConfig* config)
|
|||
|
||||
pugi::xml_document doc;
|
||||
|
||||
if(boost::filesystem::exists(path))
|
||||
if(Utils::FileSystem::exists(path))
|
||||
{
|
||||
// merge files
|
||||
pugi::xml_parse_result result = doc.load_file(path.c_str());
|
||||
|
@ -394,7 +394,7 @@ void InputManager::doOnFinish()
|
|||
std::string path = getConfigPath();
|
||||
pugi::xml_document doc;
|
||||
|
||||
if(boost::filesystem::exists(path))
|
||||
if(Utils::FileSystem::exists(path))
|
||||
{
|
||||
pugi::xml_parse_result result = doc.load_file(path.c_str());
|
||||
if(!result)
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
#include "Settings.h"
|
||||
|
||||
#include "utils/FileSystemUtil.h"
|
||||
#include "Log.h"
|
||||
#include "platform.h"
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <pugixml/src/pugixml.hpp>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
Settings* Settings::sInstance = NULL;
|
||||
|
||||
|
@ -185,7 +187,7 @@ void Settings::loadFile()
|
|||
{
|
||||
const std::string path = getHomePath() + "/.emulationstation/es_settings.cfg";
|
||||
|
||||
if(!boost::filesystem::exists(path))
|
||||
if(!Utils::FileSystem::exists(path))
|
||||
return;
|
||||
|
||||
pugi::xml_document doc;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "components/ImageComponent.h"
|
||||
#include "components/TextComponent.h"
|
||||
#include "utils/FileSystemUtil.h"
|
||||
#include "Log.h"
|
||||
#include "platform.h"
|
||||
#include "Settings.h"
|
||||
|
@ -205,7 +206,7 @@ void ThemeData::loadFile(std::map<std::string, std::string> sysDataMap, const st
|
|||
ThemeException error;
|
||||
error.setFiles(mPaths);
|
||||
|
||||
if(!boost::filesystem::exists(path))
|
||||
if(!Utils::FileSystem::exists(path))
|
||||
throw error << "File does not exist!";
|
||||
|
||||
mVersion = 0;
|
||||
|
@ -484,7 +485,7 @@ const std::shared_ptr<ThemeData>& ThemeData::getDefault()
|
|||
theme = std::shared_ptr<ThemeData>(new ThemeData());
|
||||
|
||||
const std::string path = getHomePath() + "/.emulationstation/es_theme_default.xml";
|
||||
if(boost::filesystem::exists(path))
|
||||
if(Utils::FileSystem::exists(path))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -544,12 +545,12 @@ std::map<std::string, ThemeSet> ThemeData::getThemeSets()
|
|||
|
||||
for(size_t i = 0; i < pathCount; i++)
|
||||
{
|
||||
if(!boost::filesystem::is_directory(paths[i]))
|
||||
if(!Utils::FileSystem::isDirectory(paths[i].generic_string()))
|
||||
continue;
|
||||
|
||||
for(boost::filesystem::directory_iterator it(paths[i]); it != end; ++it)
|
||||
{
|
||||
if(boost::filesystem::is_directory(*it))
|
||||
if(Utils::FileSystem::isDirectory((*it).path().generic_string()))
|
||||
{
|
||||
ThemeSet set = {*it};
|
||||
sets[set.getName()] = set;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "Util.h"
|
||||
|
||||
#include "utils/FileSystemUtil.h"
|
||||
#include "platform.h"
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
|
||||
|
@ -27,7 +28,7 @@ std::string strToUpper(const std::string& str)
|
|||
// embedded resources, e.g. ":/font.ttf", need to be properly handled too
|
||||
std::string getCanonicalPath(const std::string& path)
|
||||
{
|
||||
if(path.empty() || !boost::filesystem::exists(path))
|
||||
if(path.empty() || !Utils::FileSystem::exists(path))
|
||||
return path;
|
||||
|
||||
return boost::filesystem::canonical(path).generic_string();
|
||||
|
@ -83,14 +84,14 @@ boost::filesystem::path removeCommonPathUsingStrings(const boost::filesystem::pa
|
|||
boost::filesystem::path removeCommonPath(const boost::filesystem::path& path, const boost::filesystem::path& relativeTo, bool& contains)
|
||||
{
|
||||
// if either of these doesn't exist, boost::filesystem::canonical() is going to throw an error
|
||||
if(!boost::filesystem::exists(path) || !boost::filesystem::exists(relativeTo))
|
||||
if(!Utils::FileSystem::exists(path.generic_string()) || !Utils::FileSystem::exists(relativeTo.generic_string()))
|
||||
{
|
||||
contains = false;
|
||||
return path;
|
||||
}
|
||||
|
||||
// if it's a symlink we don't want to apply boost::filesystem::canonical on it, otherwise we'll lose the current parent_path
|
||||
boost::filesystem::path p = (boost::filesystem::is_symlink(path) ? boost::filesystem::canonical(path.parent_path()) / path.filename() : boost::filesystem::canonical(path));
|
||||
boost::filesystem::path p = (Utils::FileSystem::isSymlink(path.generic_string()) ? boost::filesystem::canonical(path.parent_path()) / path.filename() : boost::filesystem::canonical(path));
|
||||
boost::filesystem::path r = boost::filesystem::canonical(relativeTo);
|
||||
|
||||
if(p.root_path() != r.root_path())
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#include "components/VideoComponent.h"
|
||||
|
||||
#include "resources/ResourceManager.h"
|
||||
#include "utils/FileSystemUtil.h"
|
||||
#include "PowerSaver.h"
|
||||
#include "Renderer.h"
|
||||
#include "ThemeData.h"
|
||||
#include "Util.h"
|
||||
#include "Window.h"
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <SDL_timer.h>
|
||||
|
||||
#define FADE_TIME_MS 200
|
||||
|
@ -75,8 +75,8 @@ VideoComponent::VideoComponent(Window* window) :
|
|||
}
|
||||
|
||||
std::string path = getTitleFolder();
|
||||
if(!boost::filesystem::exists(path))
|
||||
boost::filesystem::create_directory(path);
|
||||
if(!Utils::FileSystem::exists(path))
|
||||
Utils::FileSystem::createDirectory(path);
|
||||
}
|
||||
|
||||
VideoComponent::~VideoComponent()
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
#include "components/TextComponent.h"
|
||||
#include "guis/GuiInputConfig.h"
|
||||
#include "utils/FileSystemUtil.h"
|
||||
#include "InputManager.h"
|
||||
#include "PowerSaver.h"
|
||||
#include "Renderer.h"
|
||||
#include "Util.h"
|
||||
#include "Window.h"
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
|
||||
#define HOLD_TIME 1000
|
||||
|
||||
|
@ -102,7 +102,7 @@ void GuiDetectDevice::update(int deltaTime)
|
|||
if(mHoldingConfig)
|
||||
{
|
||||
// If ES starts and if a known device is connected after startup skip controller configuration
|
||||
if(mFirstRun && boost::filesystem::exists(InputManager::getConfigPath()) && InputManager::getInstance()->getNumConfiguredDevices() > 0)
|
||||
if(mFirstRun && Utils::FileSystem::exists(InputManager::getConfigPath()) && InputManager::getInstance()->getNumConfiguredDevices() > 0)
|
||||
{
|
||||
if(mDoneCallback)
|
||||
mDoneCallback();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "ResourceManager.h"
|
||||
|
||||
#include "../data/Resources.h"
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include "utils/FileSystemUtil.h"
|
||||
#include <fstream>
|
||||
|
||||
auto array_deleter = [](unsigned char* p) { delete[] p; };
|
||||
|
@ -37,7 +37,7 @@ const ResourceData ResourceManager::getFileData(const std::string& path) const
|
|||
}
|
||||
|
||||
//it's not embedded; load the file
|
||||
if(!boost::filesystem::exists(path))
|
||||
if(!Utils::FileSystem::exists(path))
|
||||
{
|
||||
//if the file doesn't exist, return an "empty" ResourceData
|
||||
ResourceData data = {NULL, 0};
|
||||
|
@ -71,7 +71,7 @@ bool ResourceManager::fileExists(const std::string& path) const
|
|||
if(res2hMap.find(path) != res2hMap.cend())
|
||||
return true;
|
||||
|
||||
return boost::filesystem::exists(path);
|
||||
return Utils::FileSystem::exists(path);
|
||||
}
|
||||
|
||||
void ResourceManager::unloadAll()
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace Utils
|
|||
{
|
||||
stringList getDirContent(const std::string& _path)
|
||||
{
|
||||
std::string path = genericPath(_path);
|
||||
std::string path = getGenericPath(_path);
|
||||
stringList contentList;
|
||||
|
||||
// only parse the directory, if it's a directory
|
||||
|
@ -90,7 +90,7 @@ namespace Utils
|
|||
// this should give us something like "/home/YOUR_USERNAME" on Linux and "C:/Users/YOUR_USERNAME/" on Windows
|
||||
std::string envHome(getenv("HOME"));
|
||||
if(envHome.length())
|
||||
path = genericPath(envHome);
|
||||
path = getGenericPath(envHome);
|
||||
|
||||
#if defined(_WIN32)
|
||||
// but does not seem to work for Windows XP or Vista, so try something else
|
||||
|
@ -99,7 +99,7 @@ namespace Utils
|
|||
std::string envDir(getenv("HOMEDRIVE"));
|
||||
std::string envPath(getenv("HOMEPATH"));
|
||||
if(envDir.length() && envPath.length())
|
||||
path = genericPath(envDir + "/" + envPath);
|
||||
path = getGenericPath(envDir + "/" + envPath);
|
||||
}
|
||||
#endif // _WIN32
|
||||
|
||||
|
@ -115,11 +115,11 @@ namespace Utils
|
|||
char temp[512];
|
||||
|
||||
// return current working directory path
|
||||
return (getcwd(temp, 512) ? genericPath(temp) : "");
|
||||
return (getcwd(temp, 512) ? getGenericPath(temp) : "");
|
||||
|
||||
} // getCWDPath
|
||||
|
||||
std::string genericPath(const std::string& _path)
|
||||
std::string getGenericPath(const std::string& _path)
|
||||
{
|
||||
std::string path = _path;
|
||||
size_t offset = std::string::npos;
|
||||
|
@ -139,11 +139,11 @@ namespace Utils
|
|||
// return generic path
|
||||
return path;
|
||||
|
||||
} // genericPath
|
||||
} // getGenericPath
|
||||
|
||||
std::string escapedPath(const std::string& _path)
|
||||
std::string getEscapedPath(const std::string& _path)
|
||||
{
|
||||
std::string path = genericPath(_path);
|
||||
std::string path = getGenericPath(_path);
|
||||
|
||||
#if defined(_WIN32)
|
||||
// windows escapes stuff by just putting everything in quotes
|
||||
|
@ -166,11 +166,11 @@ namespace Utils
|
|||
return path;
|
||||
#endif // _WIN32
|
||||
|
||||
} // escapedPath
|
||||
} // getEscapedPath
|
||||
|
||||
std::string canonicalPath(const std::string& _path)
|
||||
std::string getCanonicalPath(const std::string& _path)
|
||||
{
|
||||
std::string path = absolutePath(_path);
|
||||
std::string path = exists(_path) ? getAbsolutePath(_path) : getGenericPath(_path);
|
||||
|
||||
// cleanup path
|
||||
bool scan = true;
|
||||
|
@ -244,78 +244,21 @@ namespace Utils
|
|||
// return canonical path
|
||||
return path;
|
||||
|
||||
} // canonicalPath
|
||||
} // getCanonicalPath
|
||||
|
||||
std::string absolutePath(const std::string& _path, const std::string& _base)
|
||||
std::string getAbsolutePath(const std::string& _path, const std::string& _base)
|
||||
{
|
||||
std::string path = genericPath(_path);
|
||||
std::string base = isAbsolute(_base) ? genericPath(_base) : absolutePath(_base);
|
||||
std::string path = getGenericPath(_path);
|
||||
std::string base = isAbsolute(_base) ? getGenericPath(_base) : getAbsolutePath(_base);
|
||||
|
||||
// return absolute path
|
||||
return isAbsolute(path) ? path : genericPath(base + "/" + path);
|
||||
return isAbsolute(path) ? path : getGenericPath(base + "/" + path);
|
||||
|
||||
} // absolutePath
|
||||
|
||||
std::string resolvePath(const std::string& _path, const std::string& _relativeTo, const bool _allowHome)
|
||||
{
|
||||
std::string path = genericPath(_path);
|
||||
std::string relativeTo = isDirectory(_relativeTo) ? _relativeTo : getParent(_relativeTo);
|
||||
|
||||
// nothing to resolve
|
||||
if(!path.length())
|
||||
return path;
|
||||
|
||||
// replace '.' with relativeTo
|
||||
if(path[0] == '.')
|
||||
return genericPath(relativeTo + "/" + &(path[1]));
|
||||
|
||||
// replace '~' with homePath
|
||||
if(_allowHome && (path[0] == '~'))
|
||||
return genericPath(getHomePath() + "/" + &(path[1]));
|
||||
|
||||
// nothing to resolve
|
||||
return path;
|
||||
|
||||
} // resolvePath
|
||||
|
||||
std::string resolveSymlink(const std::string& _path)
|
||||
{
|
||||
std::string path = genericPath(_path);
|
||||
std::string resolved;
|
||||
|
||||
#if defined(_WIN32)
|
||||
HANDLE hFile = CreateFile(path.c_str(), FILE_READ_ATTRIBUTES, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
|
||||
|
||||
if(hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
resolved.resize(GetFinalPathNameByHandle(hFile, nullptr, 0, FILE_NAME_NORMALIZED) + 1);
|
||||
if(GetFinalPathNameByHandle(hFile, (LPSTR)resolved.data(), (DWORD)resolved.size(), FILE_NAME_NORMALIZED) > 0)
|
||||
{
|
||||
resolved.resize(resolved.size() - 1);
|
||||
resolved = genericPath(resolved);
|
||||
}
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
#else // _WIN32
|
||||
struct stat info;
|
||||
|
||||
// check if lstat succeeded
|
||||
if(lstat(path.c_str(), &info) == 0)
|
||||
{
|
||||
resolved.resize(info.st_size);
|
||||
if(readlink(path.c_str(), (char*)resolved.data(), resolved.size()) > 0)
|
||||
resolved = genericPath(resolved);
|
||||
}
|
||||
#endif // _WIN32
|
||||
|
||||
// return resolved path
|
||||
return resolved;
|
||||
|
||||
} // resolveSymlink
|
||||
} // getAbsolutePath
|
||||
|
||||
std::string getParent(const std::string& _path)
|
||||
{
|
||||
std::string path = genericPath(_path);
|
||||
std::string path = getGenericPath(_path);
|
||||
size_t offset = std::string::npos;
|
||||
|
||||
// find last '/' and erase it
|
||||
|
@ -329,7 +272,7 @@ namespace Utils
|
|||
|
||||
std::string getFileName(const std::string& _path)
|
||||
{
|
||||
std::string path = genericPath(_path);
|
||||
std::string path = getGenericPath(_path);
|
||||
size_t offset = std::string::npos;
|
||||
|
||||
// find last '/' and return the filename
|
||||
|
@ -377,9 +320,112 @@ namespace Utils
|
|||
|
||||
} // getExtension
|
||||
|
||||
std::string resolveRelativePath(const std::string& _path, const std::string& _relativeTo, const bool _allowHome)
|
||||
{
|
||||
std::string path = getGenericPath(_path);
|
||||
std::string relativeTo = isDirectory(_relativeTo) ? getGenericPath(_relativeTo) : getParent(_relativeTo);
|
||||
|
||||
// nothing to resolve
|
||||
if (!path.length())
|
||||
return path;
|
||||
|
||||
// replace '.' with relativeTo
|
||||
if (path[0] == '.')
|
||||
return (relativeTo + "/" + &(path[1]));
|
||||
|
||||
// replace '~' with homePath
|
||||
if (_allowHome && (path[0] == '~'))
|
||||
return (getHomePath() + "/" + &(path[1]));
|
||||
|
||||
// nothing to resolve
|
||||
return path;
|
||||
|
||||
} // resolveRelativePath
|
||||
|
||||
std::string createRelativePath(const std::string& _path, const std::string& _relativeTo, const bool _allowHome)
|
||||
{
|
||||
bool contains = false;
|
||||
std::string path = removeCommonPath(_path, _relativeTo, contains);
|
||||
|
||||
if (contains)
|
||||
{
|
||||
// success
|
||||
return ("." + path);
|
||||
}
|
||||
|
||||
if (_allowHome)
|
||||
{
|
||||
contains = false;
|
||||
std::string path = removeCommonPath(_path, getHomePath(), contains);
|
||||
|
||||
if (contains)
|
||||
{
|
||||
// success
|
||||
return ("~" + path);
|
||||
}
|
||||
}
|
||||
|
||||
// nothing to resolve
|
||||
return path;
|
||||
|
||||
} // createRelativePath
|
||||
|
||||
std::string removeCommonPath(const std::string& _path, const std::string& _common, bool& _contains)
|
||||
{
|
||||
std::string path = getGenericPath(_path);
|
||||
std::string common = isDirectory(_common) ? getGenericPath(_common) : getParent(_common);
|
||||
|
||||
// check if path contains common
|
||||
if (path.find_first_of(common) == 0)
|
||||
{
|
||||
_contains = true;
|
||||
return path.substr(common.length() + 1);
|
||||
}
|
||||
|
||||
// it didn't
|
||||
_contains = false;
|
||||
return path;
|
||||
|
||||
} // removeCommonPath
|
||||
|
||||
std::string resolveSymlink(const std::string& _path)
|
||||
{
|
||||
std::string path = getGenericPath(_path);
|
||||
std::string resolved;
|
||||
|
||||
#if defined(_WIN32)
|
||||
HANDLE hFile = CreateFile(path.c_str(), FILE_READ_ATTRIBUTES, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
|
||||
|
||||
if (hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
resolved.resize(GetFinalPathNameByHandle(hFile, nullptr, 0, FILE_NAME_NORMALIZED) + 1);
|
||||
if (GetFinalPathNameByHandle(hFile, (LPSTR)resolved.data(), (DWORD)resolved.size(), FILE_NAME_NORMALIZED) > 0)
|
||||
{
|
||||
resolved.resize(resolved.size() - 1);
|
||||
resolved = getGenericPath(resolved);
|
||||
}
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
#else // _WIN32
|
||||
struct stat info;
|
||||
|
||||
// check if lstat succeeded
|
||||
if (lstat(path.c_str(), &info) == 0)
|
||||
{
|
||||
resolved.resize(info.st_size);
|
||||
if (readlink(path.c_str(), (char*)resolved.data(), resolved.size()) > 0)
|
||||
resolved = getGenericPath(resolved);
|
||||
}
|
||||
#endif // _WIN32
|
||||
|
||||
// return resolved path
|
||||
return resolved;
|
||||
|
||||
} // resolveSymlink
|
||||
|
||||
bool removeFile(const std::string& _path)
|
||||
{
|
||||
std::string path = genericPath(_path);
|
||||
std::string path = getGenericPath(_path);
|
||||
|
||||
// don't remove if it doesn't exists
|
||||
if(!exists(path))
|
||||
|
@ -392,7 +438,7 @@ namespace Utils
|
|||
|
||||
bool createDirectory(const std::string& _path)
|
||||
{
|
||||
std::string path = genericPath(_path);
|
||||
std::string path = getGenericPath(_path);
|
||||
|
||||
// don't create if it already exists
|
||||
if(exists(path))
|
||||
|
@ -416,7 +462,7 @@ namespace Utils
|
|||
|
||||
bool exists(const std::string& _path)
|
||||
{
|
||||
std::string path = genericPath(_path);
|
||||
std::string path = getGenericPath(_path);
|
||||
struct stat info;
|
||||
|
||||
// check if stat succeeded
|
||||
|
@ -426,7 +472,7 @@ namespace Utils
|
|||
|
||||
bool isAbsolute(const std::string& _path)
|
||||
{
|
||||
std::string path = genericPath(_path);
|
||||
std::string path = getGenericPath(_path);
|
||||
|
||||
#if defined(_WIN32)
|
||||
return ((path.size() > 1) && (path[1] == ':'));
|
||||
|
@ -438,7 +484,7 @@ namespace Utils
|
|||
|
||||
bool isRegularFile(const std::string& _path)
|
||||
{
|
||||
std::string path = genericPath(_path);
|
||||
std::string path = getGenericPath(_path);
|
||||
struct stat info;
|
||||
|
||||
// check if stat succeeded
|
||||
|
@ -452,7 +498,7 @@ namespace Utils
|
|||
|
||||
bool isDirectory(const std::string& _path)
|
||||
{
|
||||
std::string path = genericPath(_path);
|
||||
std::string path = getGenericPath(_path);
|
||||
struct stat info;
|
||||
|
||||
// check if stat succeeded
|
||||
|
@ -466,7 +512,7 @@ namespace Utils
|
|||
|
||||
bool isSymlink(const std::string& _path)
|
||||
{
|
||||
std::string path = genericPath(_path);
|
||||
std::string path = getGenericPath(_path);
|
||||
|
||||
#if defined(_WIN32)
|
||||
// check for symlink attribute
|
||||
|
@ -491,7 +537,7 @@ namespace Utils
|
|||
|
||||
bool isHidden(const std::string& _path)
|
||||
{
|
||||
std::string path = genericPath(_path);
|
||||
std::string path = getGenericPath(_path);
|
||||
|
||||
#if defined(_WIN32)
|
||||
// check for hidden attribute
|
||||
|
@ -511,8 +557,8 @@ namespace Utils
|
|||
|
||||
bool isEquivalent(const std::string& _path1, const std::string& _path2)
|
||||
{
|
||||
std::string path1 = genericPath(_path1);
|
||||
std::string path2 = genericPath(_path2);
|
||||
std::string path1 = getGenericPath(_path1);
|
||||
std::string path2 = getGenericPath(_path2);
|
||||
struct stat info1;
|
||||
struct stat info2;
|
||||
|
||||
|
|
|
@ -14,18 +14,20 @@ namespace Utils
|
|||
stringList getDirContent (const std::string& _path);
|
||||
std::string getHomePath ();
|
||||
std::string getCWDPath ();
|
||||
std::string genericPath (const std::string& _path);
|
||||
std::string escapedPath (const std::string& _path);
|
||||
std::string canonicalPath (const std::string& _path);
|
||||
std::string absolutePath (const std::string& _path, const std::string& _base = getCWDPath());
|
||||
std::string resolvePath (const std::string& _path, const std::string& _relativeTo, const bool _allowHome);
|
||||
std::string resolveSymlink (const std::string& _path);
|
||||
std::string getGenericPath (const std::string& _path);
|
||||
std::string getEscapedPath (const std::string& _path);
|
||||
std::string getCanonicalPath (const std::string& _path);
|
||||
std::string getAbsolutePath (const std::string& _path, const std::string& _base = getCWDPath());
|
||||
std::string getParent (const std::string& _path);
|
||||
std::string getFileName (const std::string& _path);
|
||||
std::string getStem (const std::string& _path);
|
||||
std::string getExtension (const std::string& _path);
|
||||
std::string resolveRelativePath(const std::string& _path, const std::string& _relativeTo, const bool _allowHome);
|
||||
std::string createRelativePath (const std::string& _path, const std::string& _relativeTo, const bool _allowHome);
|
||||
std::string removeCommonPath (const std::string& _path, const std::string& _common, bool& _contains);
|
||||
std::string resolveSymlink (const std::string& _path);
|
||||
bool removeFile (const std::string& _path);
|
||||
bool createDirectory(const std::string& _path);
|
||||
bool createDirectory (const std::string& _path);
|
||||
bool exists (const std::string& _path);
|
||||
bool isAbsolute (const std::string& _path);
|
||||
bool isRegularFile (const std::string& _path);
|
||||
|
|
Loading…
Reference in a new issue