| 2436 | } |
| 2437 | |
| 2438 | wxLongLong 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 |
| 2465 | void ProjectFileIO::ShowError(const BasicUI::WindowPlacement &placement, |
no test coverage detected