diff src/core/filesystem.cc @ 158:80d6b28eb29f

dep/animia: fix most X11 stuff it looks like _NET_WM_PID isn't supported by MOST clients, or my code is wrong... core/filesystem: fix Linux config path handling on *nix
author Paper <mrpapersonic@gmail.com>
date Fri, 17 Nov 2023 02:07:33 -0500
parents 28842a8d0c6b
children 121c2d5b321f
line wrap: on
line diff
--- a/src/core/filesystem.cc	Thu Nov 16 16:51:34 2023 -0500
+++ b/src/core/filesystem.cc	Fri Nov 17 02:07:33 2023 -0500
@@ -27,7 +27,12 @@
 /* this runs fs::create_directories() on the
    PARENT directory. */
 void CreateDirectories(const std::filesystem::path& path) {
-	std::filesystem::create_directories(path.parent_path());
+	if (path.empty())
+		return;
+
+	const auto& parent = path.parent_path();
+	if (!std::filesystem::exists(parent))
+		std::filesystem::create_directories(parent);
 }
 
 std::filesystem::path GetDotPath() {
@@ -49,8 +54,8 @@
 	if (!home)
 		home = getpwuid(getuid())->pw_dir;
 #	endif // __linux__
-	if (!home)
-		return std::filesystem::path(home) / ".config";
+	if (home)
+		return std::filesystem::path(home) / ".config" / CONFIG_DIR;
 	else
 		return std::filesystem::path();
 #endif     // !WIN32 && !MACOSX