Disk: add option --disk-hidden-folders

This commit is contained in:
李通洲
2025-05-19 16:42:11 +08:00
committed by Carter Li
parent 526868e355
commit 8eb8f710d0
9 changed files with 37 additions and 10 deletions
+13 -4
View File
@@ -1,6 +1,6 @@
#include "disk.h"
bool ffDiskMatchMountpoint(FFDiskOptions* options, const char* mountpoint)
bool ffDiskMatchMountpoint(FFstrbuf* folders, const char* mountpoint)
{
#ifdef _WIN32
const char separator = ';';
@@ -11,12 +11,12 @@ bool ffDiskMatchMountpoint(FFDiskOptions* options, const char* mountpoint)
uint32_t mountpointLength = (uint32_t) strlen(mountpoint);
uint32_t startIndex = 0;
while(startIndex < options->folders.length)
while(startIndex < folders->length)
{
uint32_t colonIndex = ffStrbufNextIndexC(&options->folders, startIndex, separator);
uint32_t colonIndex = ffStrbufNextIndexC(folders, startIndex, separator);
uint32_t folderLength = colonIndex - startIndex;
if (folderLength == mountpointLength && memcmp(options->folders.chars + startIndex, mountpoint, mountpointLength) == 0)
if (folderLength == mountpointLength && memcmp(folders->chars + startIndex, mountpoint, mountpointLength) == 0)
return true;
startIndex = colonIndex + 1;
@@ -54,5 +54,14 @@ const char* ffDetectDisks(FFDiskOptions* options, FFlist* disks)
}
}
if (options->hiddenFolders.length)
{
FF_LIST_FOR_EACH(FFDisk, disk, *disks)
{
if (ffDiskMatchMountpoint(&options->hiddenFolders, disk->mountpoint.chars))
disk->type |= FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
}
}
return NULL;
}