From 1c598add39e60bfa97f5dbac885c72a1469c79da Mon Sep 17 00:00:00 2001 From: Carter Li Date: Tue, 15 Oct 2024 10:16:15 +0800 Subject: [PATCH] Chore (Linux): always ignore hidden files when enumerating directories --- src/detection/battery/battery_linux.c | 2 +- src/detection/brightness/brightness_linux.c | 2 +- src/detection/displayserver/linux/drm.c | 4 ++-- src/detection/packages/packages_linux.c | 2 +- src/detection/poweradapter/poweradapter_linux.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/detection/battery/battery_linux.c b/src/detection/battery/battery_linux.c index 71ea2480a..922b18a75 100644 --- a/src/detection/battery/battery_linux.c +++ b/src/detection/battery/battery_linux.c @@ -167,7 +167,7 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) struct dirent* entry; while((entry = readdir(dirp)) != NULL) { - if(ffStrEquals(entry->d_name, ".") || ffStrEquals(entry->d_name, "..")) + if(entry->d_name[0] == '.') continue; FF_AUTO_CLOSE_FD int dfd = openat(dirfd(dirp), entry->d_name, O_RDONLY | O_CLOEXEC); diff --git a/src/detection/brightness/brightness_linux.c b/src/detection/brightness/brightness_linux.c index e5d4e608a..f45fe823b 100644 --- a/src/detection/brightness/brightness_linux.c +++ b/src/detection/brightness/brightness_linux.c @@ -25,7 +25,7 @@ static const char* detectWithBacklight(FFlist* result) struct dirent* entry; while((entry = readdir(dirp)) != NULL) { - if(ffStrEquals(entry->d_name, ".") || ffStrEquals(entry->d_name, "..")) + if(entry->d_name[0] == '.') continue; ffStrbufAppendS(&backlightDir, entry->d_name); diff --git a/src/detection/displayserver/linux/drm.c b/src/detection/displayserver/linux/drm.c index 2598d80ff..a17fc4974 100644 --- a/src/detection/displayserver/linux/drm.c +++ b/src/detection/displayserver/linux/drm.c @@ -22,7 +22,7 @@ static const char* drmParseSysfs(FFDisplayServerResult* result) struct dirent* entry; while((entry = readdir(dirp)) != NULL) { - if(ffStrEquals(entry->d_name, ".") || ffStrEquals(entry->d_name, "..")) + if(entry->d_name[0] == '.') continue; ffStrbufAppendS(&drmDir, entry->d_name); @@ -185,7 +185,7 @@ FF_MAYBE_UNUSED static const char* drmGetEdidByConnId(uint32_t connId, uint8_t* struct dirent* entry; while((entry = readdir(dirp)) != NULL) { - if(ffStrEquals(entry->d_name, ".") || ffStrEquals(entry->d_name, "..")) + if(entry->d_name[0] == '.') continue; ffStrbufAppendS(&drmDir, entry->d_name); diff --git a/src/detection/packages/packages_linux.c b/src/detection/packages/packages_linux.c index 187b0bdf2..a978929c4 100644 --- a/src/detection/packages/packages_linux.c +++ b/src/detection/packages/packages_linux.c @@ -610,7 +610,7 @@ static void getPackageCountsBedrock(FFstrbuf* baseDir, FFPackagesResult* package { if(entry->d_type != DT_DIR) continue; - if(ffStrEquals(entry->d_name, ".") || ffStrEquals(entry->d_name, "..")) + if(entry->d_name[0] == '.') continue; ffStrbufAppendS(baseDir, entry->d_name); diff --git a/src/detection/poweradapter/poweradapter_linux.c b/src/detection/poweradapter/poweradapter_linux.c index 839b687b0..2dd03e73c 100644 --- a/src/detection/poweradapter/poweradapter_linux.c +++ b/src/detection/poweradapter/poweradapter_linux.c @@ -63,7 +63,7 @@ const char* ffDetectPowerAdapter(FFlist* results) struct dirent* entry; while((entry = readdir(dirp)) != NULL) { - if(ffStrEquals(entry->d_name, ".") || ffStrEquals(entry->d_name, "..")) + if(entry->d_name[0] == '.') continue; FF_AUTO_CLOSE_FD int dfd = openat(dirfd(dirp), entry->d_name, O_RDONLY | O_CLOEXEC);