diff src/core/filesystem.cpp @ 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 327e9a5c72f1
line wrap: on
line diff
--- 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