Disk: better folder detection, support removable devices ( macOS )

This commit is contained in:
李通洲
2022-09-23 19:45:23 +08:00
parent 007ded2883
commit 371b3a2d75
9 changed files with 81 additions and 47 deletions
+22
View File
@@ -0,0 +1,22 @@
#include "disk.h"
#include <sys/statvfs.h>
const char* ffDiskAutodetectFolders(FFinstance* instance, FFlist* folders)
{
FF_UNUSED(instance);
struct statvfs fsRoot;
int rootRet = statvfs(FASTFETCH_TARGET_DIR_ROOT"/", &fsRoot);
if(rootRet != 0)
return "statvfs(\"/\") failed";
ffStrbufInitS((FFstrbuf *)ffListAdd(folders), FASTFETCH_TARGET_DIR_ROOT"/");
struct statvfs fsHome;
int homeRet = statvfs(FASTFETCH_TARGET_DIR_HOME, &fsHome);
if(homeRet == 0 && (fsRoot.f_fsid != fsHome.f_fsid))
ffStrbufInitS((FFstrbuf *)ffListAdd(folders), FASTFETCH_TARGET_DIR_HOME);
return NULL;
}