From 982e8a01177464edd4a068171788a47e4baf9b1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 1 May 2024 15:52:38 +0800 Subject: [PATCH] Disk (Windows): make `/` an alias of `C:\` for `--disk-folders` --- src/data/help.json | 3 ++- src/detection/disk/disk_windows.c | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/data/help.json b/src/data/help.json index f7cdfb2ec..158cc978b 100644 --- a/src/data/help.json +++ b/src/data/help.json @@ -947,7 +947,8 @@ }, { "long": "disk-folders", - "desc": "A colon (semicolon on Windows) separated list of folder paths for the disk output", + "desc": "A colon (semicolon on Windows) separated list of folder paths to be detected", + "remark": "On Windows, a drive latter must be upper cased and end with \"\\\". \"/\" is used as an alias of the system drive. eg. \"/\" is the alias of \"C:\\\".", "arg": { "type": "path", "default": "Auto detection using mount-points" diff --git a/src/detection/disk/disk_windows.c b/src/detection/disk/disk_windows.c index 8c0890eb6..1a395e62b 100644 --- a/src/detection/disk/disk_windows.c +++ b/src/detection/disk/disk_windows.c @@ -15,6 +15,13 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); + // For cross-platform portability; used by `presets/examples/13.jsonc` + if (__builtin_expect(options->folders.length == 1 && options->folders.chars[0] == '/', 0)) + { + ffStrbufSetS(&options->folders, getenv("SystemDrive")); + ffStrbufEnsureEndsWithC(&options->folders, '\\'); + } + for(uint32_t i = 0; i < length; i++) { wchar_t* mountpoint = buf + i;