Platform: refactor; remove extra /

This commit is contained in:
李通洲
2023-02-21 10:02:04 +08:00
parent efdbeb585b
commit 92b1788825
+7 -10
View File
@@ -8,10 +8,7 @@
static void getHomeDir(FFPlatform* platform, const struct passwd* pwd)
{
const char* home = getenv("HOME");
if(!ffStrSet(home) && pwd)
home = pwd->pw_dir;
const char* home = pwd ? pwd->pw_dir : getenv("HOME");
ffStrbufAppendS(&platform->homeDir, home);
ffStrbufEnsureEndsWithC(&platform->homeDir, '/');
}
@@ -44,11 +41,11 @@ static void getConfigDirs(FFPlatform* platform)
ffPlatformPathAddEnv(&platform->configDirs, "XDG_CONFIG_DIRS");
#if !defined(__APPLE__)
ffPlatformPathAddAbsolute(&platform->configDirs, FASTFETCH_TARGET_DIR_ETC"/xdg/");
ffPlatformPathAddAbsolute(&platform->configDirs, FASTFETCH_TARGET_DIR_ETC "/xdg/");
#endif
ffPlatformPathAddAbsolute(&platform->configDirs, FASTFETCH_TARGET_DIR_ETC"/");
ffPlatformPathAddAbsolute(&platform->configDirs, FASTFETCH_TARGET_DIR_INSTALL_SYSCONF"/");
ffPlatformPathAddAbsolute(&platform->configDirs, FASTFETCH_TARGET_DIR_ETC "/");
ffPlatformPathAddAbsolute(&platform->configDirs, FASTFETCH_TARGET_DIR_INSTALL_SYSCONF "/");
}
static void getDataDirs(FFPlatform* platform)
@@ -57,13 +54,13 @@ static void getDataDirs(FFPlatform* platform)
ffPlatformPathAddHome(&platform->dataDirs, platform, ".local/share/");
#if defined(__APPLE__)
ffPlatformPathAddHome(&platform->dataDirs, platform, "/Library/Application Support/");
ffPlatformPathAddHome(&platform->dataDirs, platform, "Library/Application Support/");
#endif
ffPlatformPathAddHome(&platform->dataDirs, platform, "");
ffPlatformPathAddEnv(&platform->dataDirs, "XDG_DATA_DIRS");
ffPlatformPathAddAbsolute(&platform->dataDirs, FASTFETCH_TARGET_DIR_USR"/local/share/");
ffPlatformPathAddAbsolute(&platform->dataDirs, FASTFETCH_TARGET_DIR_USR"/share/");
ffPlatformPathAddAbsolute(&platform->dataDirs, FASTFETCH_TARGET_DIR_USR "/local/share/");
ffPlatformPathAddAbsolute(&platform->dataDirs, FASTFETCH_TARGET_DIR_USR "/share/");
}
static void getUserName(FFPlatform* platform, const struct passwd* pwd)