Skip to content

Commit 03bc2da

Browse files
committed
Fastfetch: fix loading presets in {exePath}/presets
Regression of v2.40.0
1 parent 09d683b commit 03bc2da

File tree

3 files changed

+12
-19
lines changed

3 files changed

+12
-19
lines changed

src/fastfetch.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -483,13 +483,22 @@ static void optionParseConfigFile(FFdata* data, const char* key, const char* val
483483

484484
if (instance.state.platform.exePath.length)
485485
{
486-
ffStrbufSet(&absolutePath, &instance.state.platform.exePath);
487-
ffStrbufSubstrBeforeLastC(&absolutePath, '/');
488-
ffStrbufAppendS(&absolutePath, "/");
486+
uint32_t lastSlash = ffStrbufLastIndexC(&instance.state.platform.exePath, '/') + 1;
487+
assert(lastSlash < instance.state.platform.exePath.length);
488+
489+
// Try {exePath}/
490+
ffStrbufSetNS(&absolutePath, lastSlash, instance.state.platform.exePath.chars);
489491
ffStrbufAppendS(&absolutePath, value);
490492
if (needExtension)
491493
ffStrbufAppendS(&absolutePath, ".jsonc");
494+
if (parseJsoncFile(absolutePath.chars, strictJson)) return;
492495

496+
// Try {exePath}/presets/
497+
ffStrbufSubstrBefore(&absolutePath, lastSlash);
498+
ffStrbufAppendS(&absolutePath, "presets/");
499+
ffStrbufAppendS(&absolutePath, value);
500+
if (needExtension)
501+
ffStrbufAppendS(&absolutePath, ".jsonc");
493502
if (parseJsoncFile(absolutePath.chars, strictJson)) return;
494503
}
495504

src/util/platform/FFPlatform_unix.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,6 @@ static void getDataDirs(FFPlatform* platform)
172172
#endif
173173
ffPlatformPathAddAbsolute(&platform->dataDirs, FASTFETCH_TARGET_DIR_USR "/local/share/");
174174
ffPlatformPathAddAbsolute(&platform->dataDirs, FASTFETCH_TARGET_DIR_USR "/share/");
175-
176-
if (platform->exePath.length > 0)
177-
{
178-
// Add ${currentExePath}
179-
FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateCopy(&platform->exePath);
180-
ffStrbufSubstrBeforeLastC(&path, '/');
181-
ffPlatformPathAddAbsolute(&platform->dataDirs, path.chars);
182-
}
183175
}
184176

185177
static void getUserName(FFPlatform* platform, const struct passwd* pwd)

src/util/platform/FFPlatform_windows.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,6 @@ static void getDataDirs(FFPlatform* platform)
129129
platformPathAddKnownFolder(&platform->dataDirs, &FOLDERID_RoamingAppData);
130130
platformPathAddKnownFolder(&platform->dataDirs, &FOLDERID_LocalAppData);
131131
ffPlatformPathAddHome(&platform->dataDirs, platform, "");
132-
133-
if (platform->exePath.length > 0)
134-
{
135-
// Add ${currentExePath}
136-
FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateCopy(&platform->exePath);
137-
ffStrbufSubstrBeforeLastC(&path, '/');
138-
ffPlatformPathAddAbsolute(&platform->dataDirs, path.chars);
139-
}
140132
}
141133

142134
static void getUserName(FFPlatform* platform)

0 commit comments

Comments
 (0)