mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Packages (Windows): fix scoop packages count in non-default install path
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
#include <handleapi.h>
|
||||
#include <fileapi.h>
|
||||
|
||||
static uint32_t getNumElements(const char* searchPath /* including `\*` suffix */, DWORD type)
|
||||
static uint32_t getNumElements(const char* searchPath /* including `\*` suffix */, DWORD type, const char* ignore)
|
||||
{
|
||||
uint32_t counter = 0;
|
||||
WIN32_FIND_DATAA wfd;
|
||||
@@ -14,8 +14,9 @@ static uint32_t getNumElements(const char* searchPath /* including `\*` suffix *
|
||||
{
|
||||
do // Managed to locate and create an handle to that folder.
|
||||
{
|
||||
if(wfd.dwFileAttributes & type)
|
||||
counter++;
|
||||
if(!(wfd.dwFileAttributes & type)) continue;
|
||||
if(ignore != NULL && strcasecmp(ignore, wfd.cFileName) == 0) continue;
|
||||
counter++;
|
||||
} while (FindNextFileA(hFind, &wfd));
|
||||
FindClose(hFind);
|
||||
|
||||
@@ -42,9 +43,7 @@ static void detectScoop(const FFinstance* instance, FFPackagesResult* result)
|
||||
ffStrbufAppendS(&scoopPath, instance->state.platform.homeDir.chars);
|
||||
ffStrbufAppendS(&scoopPath, "/scoop/apps/*");
|
||||
}
|
||||
result->scoop = getNumElements(scoopPath.chars, FILE_ATTRIBUTE_DIRECTORY);
|
||||
if(result->scoop > 0)
|
||||
result->scoop--; // scoop
|
||||
result->scoop = getNumElements(scoopPath.chars, FILE_ATTRIBUTE_DIRECTORY, "scoop");
|
||||
}
|
||||
|
||||
static void detectChoco(FF_MAYBE_UNUSED const FFinstance* instance, FFPackagesResult* result)
|
||||
@@ -56,9 +55,7 @@ static void detectChoco(FF_MAYBE_UNUSED const FFinstance* instance, FFPackagesRe
|
||||
char chocoPath[MAX_PATH + 3];
|
||||
strcpy(chocoPath, chocoInstall);
|
||||
strncat(chocoPath, "/lib/*", sizeof(chocoPath) - 1 - strlen(chocoPath));
|
||||
result->choco = getNumElements(chocoPath, FILE_ATTRIBUTE_DIRECTORY);
|
||||
if(result->choco > 0)
|
||||
result->choco--; // choco
|
||||
result->choco = getNumElements(chocoPath, FILE_ATTRIBUTE_DIRECTORY, "choco");
|
||||
}
|
||||
|
||||
static void detectPacman(FF_MAYBE_UNUSED const FFinstance* instance, FFPackagesResult* result)
|
||||
@@ -71,7 +68,7 @@ static void detectPacman(FF_MAYBE_UNUSED const FFinstance* instance, FFPackagesR
|
||||
char pacmanPath[MAX_PATH + 3];
|
||||
strcpy(pacmanPath, msystemPrefix);
|
||||
strncat(pacmanPath, "/../var/lib/pacman/local/*", sizeof(pacmanPath) - 1 - strlen(pacmanPath));
|
||||
result->pacman = getNumElements(pacmanPath, FILE_ATTRIBUTE_DIRECTORY);
|
||||
result->pacman = getNumElements(pacmanPath, FILE_ATTRIBUTE_DIRECTORY, NULL);
|
||||
}
|
||||
|
||||
void ffDetectPackagesImpl(const FFinstance* instance, FFPackagesResult* result)
|
||||
|
||||
Reference in New Issue
Block a user