2020-09-21 17:17:34 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-06-22 15:27:53 +00:00
|
|
|
//
|
2020-09-21 17:17:34 +00:00
|
|
|
// EmulationStation Desktop Edition
|
2020-06-22 15:27:53 +00:00
|
|
|
// FileSystemUtil.h
|
|
|
|
//
|
|
|
|
// Low-level filesystem functions.
|
2020-06-23 18:07:00 +00:00
|
|
|
// Resolve relative paths, resolve symlinks, create directories,
|
|
|
|
// remove files etc.
|
2020-06-22 15:27:53 +00:00
|
|
|
//
|
|
|
|
|
2017-11-22 21:29:52 +00:00
|
|
|
#ifndef ES_CORE_UTILS_FILE_SYSTEM_UTIL_H
|
|
|
|
#define ES_CORE_UTILS_FILE_SYSTEM_UTIL_H
|
2017-11-15 15:59:39 +00:00
|
|
|
|
Add getDirContent, getHomePath, getCWDPath, canonicalPath, absolutePath, resolvePath, resolveSymlink, getExtension, removeFile, isAbsolute, isRegularFile, isDirectory, isSymlink, isHidden and isEquivalent
Rename makeGeneric to genericPath and escapePath to escapedPath
Add toUpper
2017-12-04 23:32:04 +00:00
|
|
|
#include <list>
|
2017-11-15 15:59:39 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace Utils
|
|
|
|
{
|
2020-06-22 15:27:53 +00:00
|
|
|
namespace FileSystem
|
|
|
|
{
|
|
|
|
typedef std::list<std::string> stringList;
|
2017-11-15 15:59:39 +00:00
|
|
|
|
2021-05-30 18:46:17 +00:00
|
|
|
stringList getDirContent(const std::string& path, const bool recursive = false);
|
|
|
|
stringList getPathList(const std::string& path);
|
|
|
|
void setHomePath(const std::string& path);
|
2020-06-22 15:27:53 +00:00
|
|
|
std::string getHomePath();
|
|
|
|
std::string getCWDPath();
|
2020-07-10 17:53:33 +00:00
|
|
|
std::string getPathToBinary(const std::string& executable);
|
2021-05-30 18:46:17 +00:00
|
|
|
void setExePath(const std::string& path);
|
2020-06-22 15:27:53 +00:00
|
|
|
std::string getExePath();
|
2020-07-07 19:25:15 +00:00
|
|
|
std::string getProgramDataPath();
|
2021-05-30 18:46:17 +00:00
|
|
|
std::string getPreferredPath(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,
|
2021-07-07 18:31:46 +00:00
|
|
|
const std::string& base = getCWDPath());
|
2021-05-30 18:46:17 +00:00
|
|
|
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 expandHomePath(const std::string& path);
|
|
|
|
std::string resolveRelativePath(const std::string& path,
|
2021-07-07 18:31:46 +00:00
|
|
|
const std::string& relativeTo,
|
|
|
|
const bool allowHome);
|
2021-05-30 18:46:17 +00:00
|
|
|
std::string createRelativePath(const std::string& path,
|
2021-07-07 18:31:46 +00:00
|
|
|
const std::string& relativeTo,
|
|
|
|
const bool allowHome);
|
2021-05-30 18:46:17 +00:00
|
|
|
std::string removeCommonPath(const std::string& path,
|
2021-07-07 18:31:46 +00:00
|
|
|
const std::string& commonArg,
|
|
|
|
bool& contains);
|
2021-05-30 18:46:17 +00:00
|
|
|
std::string resolveSymlink(const std::string& path);
|
|
|
|
bool copyFile(const std::string& sourcePath,
|
2021-07-07 18:31:46 +00:00
|
|
|
const std::string& destinationPath,
|
|
|
|
bool overwrite);
|
2021-05-30 18:46:17 +00:00
|
|
|
bool renameFile(const std::string& sourcePath,
|
2021-07-07 18:31:46 +00:00
|
|
|
const std::string& destinationPath,
|
|
|
|
bool overwrite);
|
2021-05-30 18:46:17 +00:00
|
|
|
bool removeFile(const std::string& path);
|
2021-01-31 18:55:57 +00:00
|
|
|
bool removeDirectory(const std::string& path);
|
2021-05-30 18:46:17 +00:00
|
|
|
bool createDirectory(const std::string& path);
|
|
|
|
bool exists(const std::string& path);
|
|
|
|
bool driveExists(const std::string& path);
|
|
|
|
bool isAbsolute(const std::string& path);
|
|
|
|
bool isRegularFile(const std::string& path);
|
|
|
|
bool isDirectory(const std::string& path);
|
|
|
|
bool isSymlink(const std::string& path);
|
|
|
|
bool isHidden(const std::string& path);
|
2021-07-07 18:31:46 +00:00
|
|
|
} // namespace FileSystem
|
|
|
|
|
|
|
|
} // namespace Utils
|
2017-11-15 15:59:39 +00:00
|
|
|
|
2017-11-22 21:29:52 +00:00
|
|
|
#endif // ES_CORE_UTILS_FILE_SYSTEM_UTIL_H
|