COMMON: Make iconspath a Path object

This commit is contained in:
Le Philousophe 2023-09-02 22:17:36 +02:00 committed by Eugene Sandulenko
parent b97da06876
commit dc7fadef28
15 changed files with 34 additions and 37 deletions

View File

@ -542,9 +542,9 @@ void OSystem_Android::initBackend() {
LOGD("Setting DefaultSaveFileManager path to: %s", ConfMan.get("savepath").c_str());
ConfMan.registerDefault("iconspath", basePath + "/icons");
ConfMan.registerDefault("iconspath", Common::Path(basePath, Common::Path::kNativeSeparator).joinInPlace("icons"));
// TODO remove the debug message eventually
LOGD("Setting Default Icons and Shaders path to: %s", ConfMan.get("iconspath").c_str());
LOGD("Setting Default Icons and Shaders path to: %s", ConfMan.getPath("iconspath").toString(Common::Path::kNativeSeparator).c_str());
_timerManager = new DefaultTimerManager();

View File

@ -137,7 +137,7 @@ void OSystem_iOS7::initBackend() {
setTimerCallback(&OSystem_iOS7::timerHandler, 10);
ConfMan.registerDefault("iconspath", "/");
ConfMan.registerDefault("iconspath", Common::Path("/"));
EventsBaseBackend::initBackend();
}

View File

@ -89,8 +89,8 @@ Common::Path OSystem_KolibriOS::getDefaultConfigFileName() {
return _writablePath.join("scummvm.ini");
}
Common::String OSystem_KolibriOS::getDefaultIconsPath() {
return _exePath.join("icons").toString();
Common::Path OSystem_KolibriOS::getDefaultIconsPath() {
return _exePath.join("icons");
}
Common::Path OSystem_KolibriOS::getScreenshotsPath() {

View File

@ -32,7 +32,7 @@ public:
void initBackend() override;
// Default paths
Common::String getDefaultIconsPath() override;
Common::Path getDefaultIconsPath() override;
Common::Path getScreenshotsPath() override;
void addSysArchivesToSearchSet(Common::SearchSet &s, int priority) override;
const Common::Path& getExePath() const { return _exePath; }

View File

@ -252,14 +252,14 @@ Common::Path OSystem_MacOSX::getDefaultLogFileName() {
return Common::Path(prefix).join(Common::String("Library/Logs/") + appName + ".log");
}
Common::String OSystem_MacOSX::getDefaultIconsPath() {
Common::Path OSystem_MacOSX::getDefaultIconsPath() {
const Common::String defaultIconsPath = getAppSupportPathMacOSX() + "/Icons";
if (!Posix::assureDirectoryExists(defaultIconsPath)) {
return Common::String();
return Common::Path();
}
return defaultIconsPath;
return Common::Path(defaultIconsPath);
}
Common::Path OSystem_MacOSX::getDefaultDLCsPath() {

View File

@ -50,7 +50,7 @@ public:
#endif
// Default paths
Common::String getDefaultIconsPath() override;
Common::Path getDefaultIconsPath() override;
Common::Path getDefaultDLCsPath() override;
Common::Path getScreenshotsPath() override;

View File

@ -235,7 +235,7 @@ Common::String OSystem_POSIX::getXdgUserDir(const char *name) {
return directoryPath;
}
Common::String OSystem_POSIX::getDefaultIconsPath() {
Common::Path OSystem_POSIX::getDefaultIconsPath() {
Common::String iconsPath;
// On POSIX systems we follow the XDG Base Directory Specification for
@ -257,7 +257,7 @@ Common::String OSystem_POSIX::getDefaultIconsPath() {
return Common::String();
}
return Common::String::format("%s/%s", prefix, iconsPath.c_str());
return Common::Path(prefix).join(iconsPath);
}
Common::Path OSystem_POSIX::getDefaultDLCsPath() {

View File

@ -36,7 +36,7 @@ public:
void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0) override;
// Default paths
Common::String getDefaultIconsPath() override;
Common::Path getDefaultIconsPath() override;
Common::Path getDefaultDLCsPath() override;
Common::Path getScreenshotsPath() override;

View File

@ -800,11 +800,8 @@ uint32 OSystem_SDL::getDoubleClickTime() const {
}
//Not specified in base class
Common::String OSystem_SDL::getDefaultIconsPath() {
Common::String path = ConfMan.get("iconspath");
if (!path.empty() && !path.hasSuffix("/"))
path += "/";
return path;
Common::Path OSystem_SDL::getDefaultIconsPath() {
return ConfMan.getPath("iconspath");
}
// Not specified in base class

View File

@ -92,7 +92,7 @@ public:
uint32 getDoubleClickTime() const override;
// Default paths
virtual Common::String getDefaultIconsPath();
virtual Common::Path getDefaultIconsPath();
virtual Common::Path getDefaultDLCsPath();
virtual Common::Path getScreenshotsPath();

View File

@ -256,7 +256,7 @@ Common::String OSystem_Win32::getSystemLanguage() const {
return OSystem_SDL::getSystemLanguage();
}
Common::String OSystem_Win32::getDefaultIconsPath() {
Common::Path OSystem_Win32::getDefaultIconsPath() {
TCHAR iconsPath[MAX_PATH];
if (_isPortable) {
@ -265,13 +265,13 @@ Common::String OSystem_Win32::getDefaultIconsPath() {
} else {
// Use the Application Data directory of the user profile
if (!Win32::getApplicationDataDirectory(iconsPath)) {
return Common::String();
return Common::Path();
}
_tcscat(iconsPath, TEXT("\\Icons\\"));
CreateDirectory(iconsPath, nullptr);
}
return Win32::tcharToString(iconsPath);
return Common::Path(Win32::tcharToString(iconsPath), Common::Path::kNativeSeparator);
}
Common::Path OSystem_Win32::getDefaultDLCsPath() {

View File

@ -49,7 +49,7 @@ public:
Common::String getSystemLanguage() const override;
// Default paths
Common::String getDefaultIconsPath() override;
Common::Path getDefaultIconsPath() override;
Common::Path getDefaultDLCsPath() override;
Common::Path getScreenshotsPath() override;

View File

@ -160,7 +160,7 @@ protected:
//
// Icons can be either in a subfolder named "icons" or directly in the path
Common::String iconsPath = ConfMan.get("iconspath");
Common::Path iconsPath = ConfMan.getPath("iconspath");
Common::String extraPath = ConfMan.get("extrapath");
Common::String targetIcon = target + extension;
@ -174,14 +174,14 @@ if (node.exists()) \
return (path); \
}
if (!iconsPath.empty()) {
TRY_ICON_PATH(iconsPath + "/" + targetIcon);
TRY_ICON_PATH(iconsPath + "/" + qualifiedIcon);
TRY_ICON_PATH(iconsPath + "/" + gameIcon);
TRY_ICON_PATH(iconsPath + "/" + engineIcon);
TRY_ICON_PATH(iconsPath + "/icons/" + targetIcon);
TRY_ICON_PATH(iconsPath + "/icons/" + qualifiedIcon);
TRY_ICON_PATH(iconsPath + "/icons/" + gameIcon);
TRY_ICON_PATH(iconsPath + "/icons/" + engineIcon);
TRY_ICON_PATH(iconsPath.join(targetIcon));
TRY_ICON_PATH(iconsPath.join(qualifiedIcon));
TRY_ICON_PATH(iconsPath.join(gameIcon));
TRY_ICON_PATH(iconsPath.join(engineIcon));
TRY_ICON_PATH(iconsPath.join("icons/" + targetIcon));
TRY_ICON_PATH(iconsPath.join("icons/" + qualifiedIcon));
TRY_ICON_PATH(iconsPath.join("icons/" + gameIcon));
TRY_ICON_PATH(iconsPath.join("icons/" + engineIcon));
}
if (!extraPath.empty()) {

View File

@ -70,7 +70,7 @@ bool generateZipSet(SearchSet &searchSet, const char *defaultFile, const char *p
if (!dat) {
File *file = new File;
if (ConfMan.hasKey(packsPath)) {
String path(normalizePath(ConfMan.get(packsPath) + "/" + defaultFile, '/'));
Path path(ConfMan.getPath(packsPath).join(defaultFile).normalize());
if (File::exists(path))
file->open(path);

View File

@ -101,7 +101,7 @@ bool DialogState::takeOneFile() {
fileHash.erase(fname);
Common::String url = Common::String::format("https://downloads.scummvm.org/frs/icons/%s", fname.c_str());
Common::String localFile = normalizePath(ConfMan.get("iconspath") + "/" + fname, '/');
Common::Path localFile = ConfMan.getPath("iconspath").join(fname).normalize();
Networking::SessionRequest *rq = session.get(url, localFile,
new Common::Callback<DialogState, const Networking::DataResponse &>(this, &DialogState::downloadFileCallback),
@ -390,7 +390,7 @@ void DownloadPacksDialog::setError(Common::U32String &msg) {
}
void DownloadPacksDialog::calculateList() {
Common::String iconsPath = ConfMan.get("iconspath");
Common::Path iconsPath = ConfMan.getPath("iconspath");
if (iconsPath.empty()) {
Common::U32String str(_("ERROR: No icons path set"));
setError(str);
@ -435,7 +435,7 @@ void DownloadPacksDialog::calculateList() {
}
void DownloadPacksDialog::clearCache() {
Common::String iconsPath = ConfMan.get("iconspath");
Common::Path iconsPath = ConfMan.getPath("iconspath");
if (iconsPath.empty()) {
Common::U32String str(_("ERROR: No icons path set"));
setError(str);
@ -469,7 +469,7 @@ void DownloadPacksDialog::clearCache() {
// Build list of previously downloaded icon files
for (auto ic = iconFiles.begin(); ic != iconFiles.end(); ++ic) {
Common::String fname = (*ic)->getName();
Common::FSNode fs(Common::Path(iconsPath).join(fname));
Common::FSNode fs(iconsPath.join(fname));
Common::WriteStream *str = fs.createWriteStream();
// Overwrite previously downloaded pack files with dummy data