CxbxFormatPartitionByHandle: Use non-throwing std::filesystem functions

This commit is contained in:
Silent 2021-03-06 18:37:10 +01:00
parent 487ad3fa19
commit 35cd99a844
No known key found for this signature in database
GPG Key ID: AE53149BB0C45AF1
1 changed files with 4 additions and 9 deletions

View File

@ -175,17 +175,12 @@ void CxbxFormatPartitionByHandle(HANDLE hFile)
// Format the partition, by iterating through the contents and removing all files/folders within
// Previously, we deleted and re-created the folder, but that caused permission issues for some users
try
{
for (auto& directoryEntry : std::filesystem::directory_iterator(partitionPath)) {
std::filesystem::remove_all(directoryEntry);
std::error_code er;
for (const auto& directoryEntry : std::filesystem::directory_iterator(partitionPath, er)) {
if (!er) {
std::filesystem::remove_all(directoryEntry, er);
}
}
catch (std::filesystem::filesystem_error fsException)
{
printf("std::filesystem failed with message: %s\n", fsException.what());
}
printf("Formatted EmuDisk Partition%d\n", CxbxGetPartitionNumberFromHandle(hFile));
}