mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 00:03:58 +01:00
Disk: moves disk hiding by folder and FS type to detection code
Don't probe if hided Fixes #2043
This commit is contained in:
+7
-31
@@ -189,30 +189,6 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk, uint32_t index
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool isMatchFolders(FFstrbuf* folders, const FFstrbuf* path, char separator)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
uint32_t startIndex = 0;
|
||||
while(startIndex < folders->length)
|
||||
{
|
||||
uint32_t colonIndex = ffStrbufNextIndexC(folders, startIndex, separator);
|
||||
|
||||
char savedColon = folders->chars[colonIndex]; // Can be '\0' if at end
|
||||
folders->chars[colonIndex] = '\0';
|
||||
|
||||
bool matched = fnmatch(&folders->chars[startIndex], path->chars, 0) == 0;
|
||||
folders->chars[colonIndex] = savedColon;
|
||||
|
||||
if (matched) return true;
|
||||
|
||||
startIndex = colonIndex + 1;
|
||||
}
|
||||
return false;
|
||||
#else
|
||||
return ffStrbufSeparatedContain(folders, path, separator);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ffPrintDisk(FFDiskOptions* options)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY disks = ffListCreate(sizeof (FFDisk));
|
||||
@@ -224,18 +200,18 @@ bool ffPrintDisk(FFDiskOptions* options)
|
||||
return false;
|
||||
}
|
||||
|
||||
if(disks.length == 0)
|
||||
{
|
||||
ffPrintError(FF_DISK_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No disks found");
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t index = 0;
|
||||
FF_LIST_FOR_EACH(FFDisk, disk, disks)
|
||||
{
|
||||
if(__builtin_expect(options->folders.length == 0, 1) && (disk->type & ~options->showTypes))
|
||||
continue;
|
||||
|
||||
if (options->hideFolders.length && isMatchFolders(&options->hideFolders, &disk->mountpoint, FF_DISK_FOLDER_SEPARATOR))
|
||||
continue;
|
||||
|
||||
if (options->hideFS.length && ffStrbufSeparatedContain(&options->hideFS, &disk->filesystem, ':'))
|
||||
continue;
|
||||
|
||||
printDisk(options, disk, ++index);
|
||||
}
|
||||
|
||||
@@ -407,7 +383,7 @@ bool ffGenerateDiskJsonResult(FFDiskOptions* options, yyjson_mut_doc* doc, yyjso
|
||||
|
||||
if(error)
|
||||
{
|
||||
yyjson_mut_obj_add_str(doc, module, "result", error);
|
||||
yyjson_mut_obj_add_str(doc, module, "error", error);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user