mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2025-02-20 11:43:27 +08:00
Disk (Windows): add --disk-ignore-remote
This commit is contained in:
parent
c597b7ec3a
commit
c71b04ba93
@ -18,6 +18,7 @@ Features:
|
||||
* Better max CPU frequency detection support with `CPUID / 16H` instruction (CPU, Windows)
|
||||
* This requires Core I Gen 6 or newer, and with `Virtual Machine Platform` Windows feature disabled. X86 only.
|
||||
* Improve performance of nix packages detection (Packages, Linux)
|
||||
* Add option `--disk-ignore-remote` to ignore remote disks to improve performance (Disk, Windows)
|
||||
|
||||
# 2.10.2
|
||||
|
||||
|
@ -1265,6 +1265,11 @@
|
||||
"description": "Set if unknown (unable to detect sizes) volumes should be printed",
|
||||
"default": false
|
||||
},
|
||||
"ignoreRemote": {
|
||||
"type": "boolean",
|
||||
"description": "Set if remote volumes should be ignored when detecting for performance reasons. Windows only",
|
||||
"default": false
|
||||
},
|
||||
"useAvailable": {
|
||||
"type": "boolean",
|
||||
"description": "Use f_bavail (lpFreeBytesAvailableToCaller for Windows) instead of f_bfree to calculate used bytes",
|
||||
|
@ -1007,6 +1007,16 @@
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"long": "disk-ignore-remote",
|
||||
"desc": "Set if remote volumes should be ignored when detecting for performance reasons",
|
||||
"remark": "Windows only",
|
||||
"arg": {
|
||||
"type": "bool",
|
||||
"optional": true,
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"long": "disk-use-available",
|
||||
"desc": "Use f_bavail (lpFreeBytesAvailableToCaller for Windows) instead of f_bfree to calculate used bytes",
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "disk.h"
|
||||
|
||||
const char* ffDetectDisksImpl(FFlist* disks);
|
||||
const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks);
|
||||
|
||||
static int compareDisks(const FFDisk* disk1, const FFDisk* disk2)
|
||||
{
|
||||
@ -9,7 +9,7 @@ static int compareDisks(const FFDisk* disk1, const FFDisk* disk2)
|
||||
|
||||
const char* ffDetectDisks(FFDiskOptions* options, FFlist* disks)
|
||||
{
|
||||
const char* error = ffDetectDisksImpl(disks);
|
||||
const char* error = ffDetectDisksImpl(options, disks);
|
||||
|
||||
if (error) return error;
|
||||
if (disks->length == 0) return "No disks found";
|
||||
|
@ -90,7 +90,7 @@ void detectFsInfo(struct statfs* fs, FFDisk* disk)
|
||||
}
|
||||
#endif
|
||||
|
||||
const char* ffDetectDisksImpl(FFlist* disks)
|
||||
const char* ffDetectDisksImpl(FF_MAYBE_UNUSED FFDiskOptions* options, FFlist* disks)
|
||||
{
|
||||
int size = getfsstat(NULL, 0, MNT_WAIT);
|
||||
|
||||
|
@ -250,7 +250,7 @@ static void detectStats(FFDisk* disk)
|
||||
#endif
|
||||
}
|
||||
|
||||
const char* ffDetectDisksImpl(FFlist* disks)
|
||||
const char* ffDetectDisksImpl(FF_MAYBE_UNUSED FFDiskOptions* options, FFlist* disks)
|
||||
{
|
||||
FILE* mountsFile = setmntent("/proc/mounts", "r");
|
||||
if(mountsFile == NULL)
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <winioctl.h>
|
||||
#include <assert.h>
|
||||
|
||||
const char* ffDetectDisksImpl(FFlist* disks)
|
||||
const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks)
|
||||
{
|
||||
wchar_t buf[MAX_PATH + 1];
|
||||
uint32_t length = GetLogicalDriveStringsW(sizeof(buf) / sizeof(*buf), buf);
|
||||
@ -18,7 +18,7 @@ const char* ffDetectDisksImpl(FFlist* disks)
|
||||
wchar_t* mountpoint = buf + i;
|
||||
|
||||
UINT driveType = GetDriveTypeW(mountpoint);
|
||||
if(driveType == DRIVE_NO_ROOT_DIR)
|
||||
if(driveType == DRIVE_NO_ROOT_DIR || (driveType == DRIVE_REMOTE && options->ignoreRemote))
|
||||
{
|
||||
i += (uint32_t)wcslen(mountpoint);
|
||||
continue;
|
||||
|
@ -281,6 +281,12 @@ bool ffParseDiskCommandOptions(FFDiskOptions* options, const char* key, const ch
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ffStrEqualsIgnCase(subKey, "ignore-remote"))
|
||||
{
|
||||
options->ignoreRemote = ffOptionParseBoolean(value);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ffPercentParseCommandOptions(key, subKey, value, &options->percent))
|
||||
return true;
|
||||
|
||||
@ -351,6 +357,12 @@ void ffParseDiskJsonObject(FFDiskOptions* options, yyjson_val* module)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ffStrEqualsIgnCase(key, "ignoreRemote"))
|
||||
{
|
||||
options->ignoreRemote = yyjson_get_bool(val);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ffStrEqualsIgnCase(key, "useAvailable"))
|
||||
{
|
||||
if (yyjson_get_bool(val))
|
||||
@ -398,6 +410,9 @@ void ffGenerateDiskJsonConfig(FFDiskOptions* options, yyjson_mut_doc* doc, yyjso
|
||||
if (defaultOptions.calcType != options->calcType)
|
||||
yyjson_mut_obj_add_bool(doc, module, "useAvailable", options->calcType == FF_DISK_CALC_TYPE_AVAILABLE);
|
||||
|
||||
if (defaultOptions.ignoreRemote != options->ignoreRemote)
|
||||
yyjson_mut_obj_add_bool(doc, module, "ignoreRemote", options->ignoreRemote);
|
||||
|
||||
ffPercentGenerateJsonConfig(doc, module, defaultOptions.percent, options->percent);
|
||||
}
|
||||
|
||||
|
@ -31,4 +31,5 @@ typedef struct FFDiskOptions
|
||||
FFDiskVolumeType showTypes;
|
||||
FFDiskCalcType calcType;
|
||||
FFColorRangeConfig percent;
|
||||
bool ignoreRemote;
|
||||
} FFDiskOptions;
|
||||
|
Loading…
x
Reference in New Issue
Block a user