mirror of
https://github.com/cookiengineer/audacity
synced 2025-04-30 15:49:41 +02:00
A function detecting when a file is hosted on a FAT system
This commit is contained in:
parent
2d6db518fa
commit
a628a3efbd
@ -2206,6 +2206,50 @@ bool ProjectFileIO::IsRecovered() const
|
||||
return mRecovered;
|
||||
}
|
||||
|
||||
// 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>
|
||||
static bool 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"
|
||||
static bool 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>
|
||||
static bool 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
|
||||
static bool IsOnFATFileSystem(const FilePath &path)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
wxLongLong ProjectFileIO::GetFreeDiskSpace() const
|
||||
{
|
||||
wxLongLong freeSpace;
|
||||
|
Loading…
x
Reference in New Issue
Block a user