mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-28 07:44:06 +01:00
Global: replaces NULL to nullptr
This commit is contained in:
@@ -18,7 +18,7 @@ const char* ffDetectPackages(FFPackagesResult* result, FFPackagesOptions* option
|
||||
result->all += ((uint32_t*) result)[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool ffPackagesReadCache(FFstrbuf* cacheDir, FFstrbuf* cacheContent, const char* filePath, const char* packageId, uint32_t* result) {
|
||||
@@ -36,7 +36,7 @@ bool ffPackagesReadCache(FFstrbuf* cacheDir, FFstrbuf* cacheContent, const char*
|
||||
|
||||
uint64_t mtime_current = (uint64_t) st.st_mtim.tv_sec * 1000ull + (uint64_t) st.st_mtim.tv_nsec / 1000000ull;
|
||||
#else
|
||||
FF_AUTO_CLOSE_FD HANDLE handle = CreateFileA(filePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
FF_AUTO_CLOSE_FD HANDLE handle = CreateFileA(filePath, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
|
||||
if (handle == INVALID_HANDLE_VALUE) // file doesn't exist or isn't accessible
|
||||
{
|
||||
@@ -85,14 +85,14 @@ bool ffPackagesWriteCache(FFstrbuf* cacheDir, FFstrbuf* cacheContent, uint32_t n
|
||||
#ifndef _WIN32
|
||||
uint32_t ffPackagesGetNumElements(const char* dirname, bool isdir) {
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(dirname);
|
||||
if (dirp == NULL) {
|
||||
if (dirp == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t num_elements = 0;
|
||||
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dirp)) != NULL) {
|
||||
while ((entry = readdir(dirp)) != nullptr) {
|
||||
bool ok = false;
|
||||
|
||||
if (entry->d_name[0] != '.') {
|
||||
|
||||
@@ -23,7 +23,7 @@ static uint32_t getNumStringsImpl(const char* filename, const char* needle) {
|
||||
uint32_t count = 0;
|
||||
char* iter = content.chars;
|
||||
size_t needleLength = strlen(needle);
|
||||
while ((iter = memmem(iter, content.length - (size_t) (iter - content.chars), needle, needleLength)) != NULL) {
|
||||
while ((iter = memmem(iter, content.length - (size_t) (iter - content.chars), needle, needleLength)) != nullptr) {
|
||||
++count;
|
||||
iter += needleLength;
|
||||
}
|
||||
@@ -85,7 +85,7 @@ static uint32_t countFilesRecursiveImpl(FFstrbuf* baseDirPath, const char* filen
|
||||
}
|
||||
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(baseDirPath->chars);
|
||||
if (dirp == NULL) {
|
||||
if (dirp == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ static uint32_t countFilesRecursiveImpl(FFstrbuf* baseDirPath, const char* filen
|
||||
uint32_t sum = 0;
|
||||
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dirp)) != NULL) {
|
||||
while ((entry = readdir(dirp)) != nullptr) {
|
||||
// According to the PMS, neither category nor package name can begin with '.', so no need to check for . or .. specifically
|
||||
if (entry->d_type != DT_DIR || entry->d_name[0] == '.') {
|
||||
continue;
|
||||
@@ -122,13 +122,13 @@ static uint32_t getNumElementsBySuffix(FFstrbuf* baseDir, const char* dirname, c
|
||||
ffStrbufAppendS(baseDir, dirname);
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(baseDir->chars);
|
||||
ffStrbufSubstrBefore(baseDir, baseDirLength);
|
||||
if (dirp == NULL) {
|
||||
if (dirp == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t count = 0;
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dirp)) != NULL) {
|
||||
while ((entry = readdir(dirp)) != nullptr) {
|
||||
if (entry->d_name[0] != '.' && ffStrEndsWithIgnCase(entry->d_name, suffix)) {
|
||||
++count;
|
||||
}
|
||||
@@ -138,14 +138,14 @@ static uint32_t getNumElementsBySuffix(FFstrbuf* baseDir, const char* dirname, c
|
||||
|
||||
static uint32_t getXBPSImpl(FFstrbuf* baseDir) {
|
||||
FF_AUTO_CLOSE_DIR DIR* dir = opendir(baseDir->chars);
|
||||
if (dir == NULL) {
|
||||
if (dir == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t result = 0;
|
||||
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
while ((entry = readdir(dir)) != nullptr) {
|
||||
if (entry->d_type != DT_REG || !ffStrStartsWithIgnCase(entry->d_name, "pkgdb-")) {
|
||||
continue;
|
||||
}
|
||||
@@ -198,17 +198,17 @@ static uint32_t getRpmFromLibrpm(void) {
|
||||
// Don't print any error messages
|
||||
ffrpmlogSetMask(RPMLOG_MASK(RPMLOG_EMERG));
|
||||
|
||||
if (ffrpmReadConfigFiles(NULL, NULL) != 0) {
|
||||
if (ffrpmReadConfigFiles(nullptr, nullptr) != 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
rpmts ts = ffrpmtsCreate();
|
||||
if (ts == NULL) {
|
||||
if (ts == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
rpmdbMatchIterator mi = ffrpmtsInitIterator(ts, RPMDBI_LABEL, NULL, 0);
|
||||
if (mi == NULL) {
|
||||
rpmdbMatchIterator mi = ffrpmtsInitIterator(ts, RPMDBI_LABEL, nullptr, 0);
|
||||
if (mi == nullptr) {
|
||||
ffrpmtsFree(ts);
|
||||
return 0;
|
||||
}
|
||||
@@ -232,7 +232,7 @@ static uint32_t getAMPackages(FFstrbuf* baseDir) {
|
||||
|
||||
uint32_t result = 0;
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dirp)) != NULL) {
|
||||
while ((entry = readdir(dirp)) != nullptr) {
|
||||
if (entry->d_name[0] == '.') {
|
||||
continue;
|
||||
}
|
||||
@@ -330,14 +330,14 @@ static uint32_t getGuixPackages(FFstrbuf* baseDir, const char* dirname) {
|
||||
|
||||
static inline uint32_t getFlatpakRuntimePackagesArch(FFstrbuf* baseDir) {
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(baseDir->chars);
|
||||
if (dirp == NULL) {
|
||||
if (dirp == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t num_elements = 0;
|
||||
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dirp)) != NULL) {
|
||||
while ((entry = readdir(dirp)) != nullptr) {
|
||||
if (entry->d_type == DT_DIR && entry->d_name[0] != '.') {
|
||||
num_elements += getNumElements(baseDir, entry->d_name, true);
|
||||
}
|
||||
@@ -349,7 +349,7 @@ static inline uint32_t getFlatpakRuntimePackagesArch(FFstrbuf* baseDir) {
|
||||
static inline uint32_t getFlatpakRuntimePackages(FFstrbuf* baseDir) {
|
||||
ffStrbufAppendS(baseDir, "runtime/");
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(baseDir->chars);
|
||||
if (dirp == NULL) {
|
||||
if (dirp == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -357,7 +357,7 @@ static inline uint32_t getFlatpakRuntimePackages(FFstrbuf* baseDir) {
|
||||
uint32_t num_elements = 0;
|
||||
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dirp)) != NULL) {
|
||||
while ((entry = readdir(dirp)) != nullptr) {
|
||||
if (entry->d_type == DT_DIR && entry->d_name[0] != '.') {
|
||||
// `flatpak list` ignores `.Locale` and `.Debug` packages, and maybe others
|
||||
const char* dot = strrchr(entry->d_name, '.');
|
||||
@@ -383,7 +383,7 @@ static inline uint32_t getFlatpakRuntimePackages(FFstrbuf* baseDir) {
|
||||
static inline uint32_t getFlatpakAppPackages(FFstrbuf* baseDir) {
|
||||
ffStrbufAppendS(baseDir, "app/");
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(baseDir->chars);
|
||||
if (dirp == NULL) {
|
||||
if (dirp == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -391,7 +391,7 @@ static inline uint32_t getFlatpakAppPackages(FFstrbuf* baseDir) {
|
||||
uint32_t num_elements = 0;
|
||||
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dirp)) != NULL) {
|
||||
while ((entry = readdir(dirp)) != nullptr) {
|
||||
if (entry->d_type == DT_DIR && entry->d_name[0] != '.') {
|
||||
ffStrbufAppendS(baseDir, entry->d_name);
|
||||
ffStrbufAppendS(baseDir, "/current");
|
||||
@@ -458,13 +458,13 @@ static uint32_t getPacmanPackages(FFstrbuf* baseDir) {
|
||||
|
||||
static uint32_t getEmergePackagesImpl(FFstrbuf* baseDir) {
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(baseDir->chars);
|
||||
if (dirp == NULL)
|
||||
if (dirp == nullptr)
|
||||
return 0;
|
||||
|
||||
uint32_t result = 0;
|
||||
|
||||
struct dirent *entry;
|
||||
while ((entry = readdir(dirp)) != NULL)
|
||||
while ((entry = readdir(dirp)) != nullptr)
|
||||
{
|
||||
if (entry->d_type != DT_DIR || entry->d_name[0] == '.')
|
||||
continue;
|
||||
@@ -589,7 +589,7 @@ static void getPackageCountsBedrock(FFstrbuf* baseDir, FFPackagesResult* package
|
||||
ffStrbufAppendS(baseDir, "/bedrock/strata");
|
||||
|
||||
FF_AUTO_CLOSE_DIR DIR* dir = opendir(baseDir->chars);
|
||||
if (dir == NULL) {
|
||||
if (dir == nullptr) {
|
||||
ffStrbufSubstrBefore(baseDir, baseDirLength);
|
||||
return;
|
||||
}
|
||||
@@ -598,7 +598,7 @@ static void getPackageCountsBedrock(FFstrbuf* baseDir, FFPackagesResult* package
|
||||
uint32_t baseDirLength2 = baseDir->length;
|
||||
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
while ((entry = readdir(dir)) != nullptr) {
|
||||
if (entry->d_type != DT_DIR) {
|
||||
continue;
|
||||
}
|
||||
@@ -620,8 +620,8 @@ static uint32_t getInstallReleasePackages(FFstrbuf* baseDir) {
|
||||
uint32_t baseDirLength = baseDir->length;
|
||||
ffStrbufAppendS(baseDir, ".config/install_release/state.json");
|
||||
if (ffPathExists(baseDir->chars, FF_PATHTYPE_ANY)) {
|
||||
yyjson_doc* doc = yyjson_read_file(baseDir->chars, YYJSON_READ_NOFLAG, NULL, NULL);
|
||||
if (doc != NULL) {
|
||||
yyjson_doc* doc = yyjson_read_file(baseDir->chars, YYJSON_READ_NOFLAG, nullptr, nullptr);
|
||||
if (doc != nullptr) {
|
||||
yyjson_val* root = yyjson_doc_get_root(doc);
|
||||
if (yyjson_is_obj(root)) {
|
||||
result = (uint32_t) yyjson_obj_size(root);
|
||||
|
||||
@@ -101,7 +101,7 @@ static uint32_t getNixPackagesImpl(char* path) {
|
||||
FF_STRBUF_AUTO_DESTROY cacheHash = ffStrbufCreateA(64);
|
||||
uint32_t count = 0;
|
||||
|
||||
ffProcessAppendStdOut(&hash, (char* const[]) { "nix-store", "--query", "--hash", path, NULL });
|
||||
ffProcessAppendStdOut(&hash, (char* const[]) { "nix-store", "--query", "--hash", path, nullptr });
|
||||
|
||||
if (checkNixCache(&cacheDir, &cacheHash, &count) && ffStrbufEqual(&hash, &cacheHash)) {
|
||||
return count;
|
||||
@@ -115,7 +115,7 @@ static uint32_t getNixPackagesImpl(char* path) {
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY output = ffStrbufCreateA(1024);
|
||||
|
||||
ffProcessAppendStdOut(&output, (char* const[]) { "nix-store", "--query", "--requisites", path, NULL });
|
||||
ffProcessAppendStdOut(&output, (char* const[]) { "nix-store", "--query", "--requisites", path, nullptr });
|
||||
|
||||
uint32_t lineLength = 0;
|
||||
for (uint32_t i = 0; i < output.length; i++) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
void ffDetectPackagesImpl(FFPackagesResult* result, FFPackagesOptions* options) {
|
||||
if (FF_PACKAGES_IS_ENABLED(options, PKG)) {
|
||||
yyjson_doc* doc = yyjson_read_file(FASTFETCH_TARGET_DIR_ROOT "/var/pkg/state/installed/catalog.attrs", YYJSON_READ_NOFLAG, NULL, NULL);
|
||||
yyjson_doc* doc = yyjson_read_file(FASTFETCH_TARGET_DIR_ROOT "/var/pkg/state/installed/catalog.attrs", YYJSON_READ_NOFLAG, nullptr, nullptr);
|
||||
if (doc) {
|
||||
yyjson_val* packageCount = yyjson_obj_get(yyjson_doc_get_root(doc), "package-count");
|
||||
if (packageCount) {
|
||||
|
||||
@@ -13,12 +13,12 @@
|
||||
#include <shlobj.h>
|
||||
|
||||
static uint32_t getNumElements(const char* searchPath, DWORD type, const wchar_t* ignore) {
|
||||
FF_AUTO_CLOSE_FD HANDLE dfd = CreateFileA(searchPath, FILE_LIST_DIRECTORY | SYNCHRONIZE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
|
||||
FF_AUTO_CLOSE_FD HANDLE dfd = CreateFileA(searchPath, FILE_LIST_DIRECTORY | SYNCHRONIZE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
|
||||
if (dfd == INVALID_HANDLE_VALUE) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool flag = ignore == NULL;
|
||||
bool flag = ignore == nullptr;
|
||||
uint32_t counter = 0;
|
||||
alignas(8) uint8_t buffer[64 * 1024];
|
||||
BOOLEAN firstScan = TRUE;
|
||||
@@ -29,15 +29,15 @@ static uint32_t getNumElements(const char* searchPath, DWORD type, const wchar_t
|
||||
IO_STATUS_BLOCK ioStatus = {};
|
||||
NTSTATUS status = NtQueryDirectoryFile(
|
||||
dfd,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
&ioStatus,
|
||||
buffer,
|
||||
ARRAY_SIZE(buffer),
|
||||
FileDirectoryInformation,
|
||||
FALSE,
|
||||
NULL,
|
||||
nullptr,
|
||||
firstScan);
|
||||
firstScan = FALSE;
|
||||
|
||||
@@ -90,13 +90,13 @@ static void detectScoop(FFPackagesResult* result) {
|
||||
ffStrbufAppend(&scoopPath, &instance.state.platform.homeDir);
|
||||
ffStrbufAppendS(&scoopPath, ".config/scoop/config.json");
|
||||
|
||||
yyjson_val* root = NULL;
|
||||
yyjson_val* root = nullptr;
|
||||
|
||||
yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_file(scoopPath.chars, 0, NULL, NULL);
|
||||
yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_file(scoopPath.chars, 0, nullptr, nullptr);
|
||||
if (doc) {
|
||||
root = yyjson_doc_get_root(doc);
|
||||
if (!yyjson_is_obj(root)) {
|
||||
root = NULL;
|
||||
root = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,8 +119,8 @@ static void detectScoop(FFPackagesResult* result) {
|
||||
ffStrbufSetJsonVal(&scoopPath, yyjson_obj_get(root, "global_path"));
|
||||
}
|
||||
if (scoopPath.length == 0) {
|
||||
PWSTR pPath = NULL;
|
||||
if (SUCCEEDED(SHGetKnownFolderPath(&FOLDERID_ProgramData, KF_FLAG_DEFAULT, NULL, &pPath))) {
|
||||
PWSTR pPath = nullptr;
|
||||
if (SUCCEEDED(SHGetKnownFolderPath(&FOLDERID_ProgramData, KF_FLAG_DEFAULT, nullptr, &pPath))) {
|
||||
ffStrbufSetWS(&scoopPath, pPath);
|
||||
CoTaskMemFree(pPath);
|
||||
}
|
||||
@@ -153,7 +153,7 @@ static void detectPacman(FFPackagesResult* result) {
|
||||
char pacmanPath[MAX_PATH + 3];
|
||||
char* pend = ffStrCopy(pacmanPath, msystemPrefix, ARRAY_SIZE(pacmanPath));
|
||||
ffStrCopy(pend, "/../var/lib/pacman/local/", ARRAY_SIZE(pacmanPath) - (size_t) (pend - pacmanPath));
|
||||
result->pacman = getNumElements(pacmanPath, FILE_ATTRIBUTE_DIRECTORY, NULL);
|
||||
result->pacman = getNumElements(pacmanPath, FILE_ATTRIBUTE_DIRECTORY, nullptr);
|
||||
}
|
||||
|
||||
static void detectWinget(FFPackagesResult* result) {
|
||||
@@ -162,7 +162,7 @@ static void detectWinget(FFPackagesResult* result) {
|
||||
"winget.exe",
|
||||
"list",
|
||||
"--disable-interactivity",
|
||||
NULL,
|
||||
nullptr,
|
||||
})) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user