mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 10:22:12 +02:00
Packages: detect pacman package count inside MSYS2 env (Windows)
This commit is contained in:
@@ -26,6 +26,7 @@ Features:
|
||||
* Add Wifi module support for Linux
|
||||
* Detect scaled resolutions (Windows, macOS)
|
||||
* Optimise font module printing (Windows)
|
||||
* Detect pacman package count inside MSYS2 environment (Windows)
|
||||
|
||||
Logos:
|
||||
* Raspbian (@IamNoRobot, #373)
|
||||
|
||||
@@ -17,10 +17,10 @@ static uint32_t getNumElements(const char* searchPath /* including `\*` suffix *
|
||||
counter++;
|
||||
} while (FindNextFileA(hFind, &wfd));
|
||||
FindClose(hFind);
|
||||
}
|
||||
|
||||
if(type == FILE_ATTRIBUTE_DIRECTORY && counter >= 2)
|
||||
counter -= 2; // accounting for . and ..
|
||||
if(type == FILE_ATTRIBUTE_DIRECTORY && counter >= 2)
|
||||
counter -= 2; // accounting for . and ..
|
||||
}
|
||||
|
||||
return counter;
|
||||
}
|
||||
@@ -35,10 +35,8 @@ static void detectScoop(const FFinstance* instance, FFPackagesResult* result)
|
||||
result->scoop--; // scoop
|
||||
}
|
||||
|
||||
static void detectChoco(const FFinstance* instance, FFPackagesResult* result)
|
||||
static void detectChoco(FF_MAYBE_UNUSED const FFinstance* instance, FFPackagesResult* result)
|
||||
{
|
||||
FF_UNUSED(instance);
|
||||
|
||||
const char* chocoInstall = getenv("ChocolateyInstall");
|
||||
if(!chocoInstall || chocoInstall[0] == '\0')
|
||||
return;
|
||||
@@ -51,8 +49,22 @@ static void detectChoco(const FFinstance* instance, FFPackagesResult* result)
|
||||
result->choco--; // choco
|
||||
}
|
||||
|
||||
static void detectPacman(FF_MAYBE_UNUSED const FFinstance* instance, FFPackagesResult* result)
|
||||
{
|
||||
const char* msystemPrefix = getenv("MSYSTEM_PREFIX");
|
||||
if(!msystemPrefix)
|
||||
return;
|
||||
|
||||
// MSYS2
|
||||
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);
|
||||
}
|
||||
|
||||
void ffDetectPackagesImpl(const FFinstance* instance, FFPackagesResult* result)
|
||||
{
|
||||
detectScoop(instance, result);
|
||||
detectChoco(instance, result);
|
||||
detectPacman(instance, result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user