MCPcopy Create free account
hub / github.com/audacity/audacity / GetFreeDiskSpace

Method GetFreeDiskSpace

libraries/lib-project-file-io/ProjectFileIO.cpp:2438–2462  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2436}
2437
2438wxLongLong ProjectFileIO::GetFreeDiskSpace() const
2439{
2440 wxLongLong freeSpace;
2441 if (wxGetDiskSpace(wxPathOnly(mFileName), NULL, &freeSpace))
2442 {
2443 if (FileNames::IsOnFATFileSystem(mFileName)) {
2444 // 4 GiB per-file maximum
2445 constexpr auto limit = 1ll << 32;
2446
2447 // Opening a file only to find its length looks wasteful but
2448 // seems to be necessary at least on Windows with FAT filesystems.
2449 // I don't know if that is only a wxWidgets bug.
2450 auto length = wxFile{mFileName}.Length();
2451 // auto length = wxFileName::GetSize(mFileName);
2452
2453 if (length == wxInvalidSize)
2454 length = 0;
2455 auto free = std::max<wxLongLong>(0, limit - length);
2456 freeSpace = std::min(freeSpace, free);
2457 }
2458 return freeSpace;
2459 }
2460
2461 return -1;
2462}
2463
2464/// Displays an error dialog with a button that offers help
2465void ProjectFileIO::ShowError(const BasicUI::WindowPlacement &placement,

Callers 3

OnTimerMethod · 0.80
CompactMethod · 0.80

Calls 2

LengthMethod · 0.80
minFunction · 0.50

Tested by

no test coverage detected