Mercurial > minori
changeset 45:4b05bc7668eb
filesystem: split config path into dotpath and config, add anime db path
EVENTUALLY I'll get around to saving the anime db and list...
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Fri, 22 Sep 2023 15:21:55 -0400 |
parents | 619cbd6e69f9 |
children | d0adc4aedfc8 |
files | include/core/filesystem.h src/core/filesystem.cpp |
diffstat | 2 files changed, 22 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/include/core/filesystem.h Fri Sep 22 13:52:11 2023 -0400 +++ b/include/core/filesystem.h Fri Sep 22 15:21:55 2023 -0400 @@ -7,7 +7,9 @@ bool CreateDirectories(std::string path); bool Exists(std::string path); std::string GetParentDirectory(std::string path); -std::string GetConfigPath(); +std::string GetDotPath(); // %APPDATA%/minori, ~/Library/Application Support/minori, ~/.config/minori... +std::string GetConfigPath(); // (dotpath)/config.json +std::string GetAnimeDBPath(); // (dotpath)/anime/db.json } // namespace Filesystem
--- a/src/core/filesystem.cpp Fri Sep 22 13:52:11 2023 -0400 +++ b/src/core/filesystem.cpp Fri Sep 22 15:21:55 2023 -0400 @@ -60,18 +60,16 @@ return path.substr(0, pos); } -std::string GetConfigPath(void) { +std::string GetDotPath(void) { std::string ret = ""; #ifdef WIN32 char buf[PATH_MAX + 1]; if (SHGetFolderPathAndSubDir(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, CONFIG_DIR, buf) == S_OK) { ret += buf; - ret += DELIM CONFIG_NAME; } #elif defined(MACOSX) - /* pass all of our problems to objc++ code */ ret += osx::GetApplicationSupportDirectory(); - ret += DELIM CONFIG_DIR DELIM CONFIG_NAME; + ret += DELIM CONFIG_DIR; #else // just assume POSIX if (getenv("HOME") != NULL) ret += getenv("HOME"); @@ -80,9 +78,25 @@ ret += getpwuid(getuid())->pw_dir; # endif // __linux__ if (!ret.empty()) - ret += DELIM ".config" DELIM CONFIG_DIR DELIM CONFIG_NAME; + ret += DELIM ".config" DELIM CONFIG_DIR; #endif // !WIN32 && !MACOSX return ret; } +std::string GetConfigPath(void) { + std::string ret = ""; + ret += GetDotPath(); + if (!ret.empty()) + ret += DELIM CONFIG_NAME; + return ret; +} + +std::string GetAnimeDBPath(void) { + std::string ret = ""; + ret += GetDotPath(); + if (!ret.empty()) + ret += DELIM "anime" DELIM "db.json"; + return ret; +} + } // namespace Filesystem