Format partitions by emptying the contents rather than deleting the folder
This commit is contained in:
parent
b459843c80
commit
b0cdc4891a
|
@ -184,14 +184,14 @@ void CxbxFormatPartitionByHandle(HANDLE hFile)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Format the partition, by deleting it's folder and re-creating it
|
|
||||||
// In this case, experimental means that these functions work and are safe
|
// Format the partition, by iterating through the contents and removing all files/folders within
|
||||||
// but not officially in the C++ standard yet
|
// Previously, we deleted and re-created the folder, but that caused permission issues for some users
|
||||||
// Requires a compiler with C++17 support
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::experimental::filesystem::remove_all(partitionPath);
|
for (auto& directoryEntry : std::experimental::filesystem::recursive_directory_iterator(partitionPath)) {
|
||||||
std::experimental::filesystem::create_directory(partitionPath);
|
std::experimental::filesystem::remove_all(directoryEntry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (std::experimental::filesystem::filesystem_error fsException)
|
catch (std::experimental::filesystem::filesystem_error fsException)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue