1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-03-28 00:55:50 +01:00

Move IsOnFATFileSystem to FileNames

This commit is contained in:
Paul Licameli
2020-12-06 12:23:19 -05:00
parent 0bd21e171c
commit c5e454e109
3 changed files with 48 additions and 45 deletions

View File

@@ -815,3 +815,48 @@ wxString FileNames::UnsavedProjectFileName()
return fn.GetFullPath();
}
// How to detect whether the file system of a path is FAT
// No apparent way to do it with wxWidgets
#if defined(__DARWIN__)
#include <sys/mount.h>
bool FileNames::IsOnFATFileSystem(const FilePath &path)
{
struct statfs fs;
if (statfs(path.c_str(), &fs))
// Error from statfs
return false;
return 0 == strcmp(fs.f_fstypename, "msdos");
}
#elif defined(__linux__)
#include <sys/statfs.h>
#include "/usr/include/linux/magic.h"
bool FileNames::IsOnFATFileSystem(const FilePath &path)
{
struct statfs fs;
if (statfs(path.c_str(), &fs))
// Error from statfs
return false;
return fs.f_type == MSDOS_SUPER_MAGIC;
}
#elif defined(_WIN32)
#include <fileapi.h>
bool FileNames::IsOnFATFileSystem(const FilePath &path)
{
DWORD volumeFlags;
wxChar volumeType[64];
if (!::GetVolumeInformation(
path.c_str(), NULL, 0, NULL, NULL,
&volumeFlags,
volumeType,
WXSIZEOF(volumeType)))
return false;
return wxString(volumeType).Upper().find(wxT("FAT")) != wxString::npos;
}
#else
bool FileNames::IsOnFATFileSystem(const FilePath &path)
{
return false;
}
#endif