mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-17 03:53:07 +01:00
Move platform_directory_delete() to Path
This commit is contained in:
@@ -104,4 +104,9 @@ namespace Path
|
||||
{
|
||||
return Platform::ResolveCasing(path, File::Exists(path));
|
||||
}
|
||||
|
||||
bool DeleteDirectory(std::string_view path)
|
||||
{
|
||||
return fs::remove_all(u8path(path)) > 0;
|
||||
}
|
||||
} // namespace Path
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace Path
|
||||
std::string GetDirectory(std::string_view path);
|
||||
void CreateDirectory(std::string_view path);
|
||||
bool DirectoryExists(std::string_view path);
|
||||
bool DeleteDirectory(std::string_view path);
|
||||
std::string GetFileName(std::string_view origPath);
|
||||
std::string GetFileNameWithoutExtension(std::string_view path);
|
||||
std::string GetExtension(std::string_view path);
|
||||
|
||||
@@ -89,11 +89,6 @@ bool platform_ensure_directory_exists(const utf8* path)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool platform_directory_delete(const utf8* path)
|
||||
{
|
||||
return fs::remove_all(u8path(path)) > 0;
|
||||
}
|
||||
|
||||
std::string platform_get_absolute_path(const utf8* relative_path, const utf8* base_path)
|
||||
{
|
||||
std::string result;
|
||||
|
||||
@@ -70,26 +70,6 @@ bool platform_ensure_directory_exists(const utf8* path)
|
||||
return success != FALSE;
|
||||
}
|
||||
|
||||
bool platform_directory_delete(const utf8* path)
|
||||
{
|
||||
// Needs to be double-null terminated as pFrom is a null terminated array of strings
|
||||
auto wPath = String::ToWideChar(path) + L"\0";
|
||||
|
||||
SHFILEOPSTRUCTW fileop;
|
||||
fileop.hwnd = nullptr; // no status display
|
||||
fileop.wFunc = FO_DELETE; // delete operation
|
||||
fileop.pFrom = wPath.c_str(); // source file name as double null terminated string
|
||||
fileop.pTo = nullptr; // no destination needed
|
||||
fileop.fFlags = FOF_NOCONFIRMATION | FOF_SILENT; // do not prompt the user
|
||||
|
||||
fileop.fAnyOperationsAborted = FALSE;
|
||||
fileop.lpszProgressTitle = nullptr;
|
||||
fileop.hNameMappings = nullptr;
|
||||
|
||||
int32_t ret = SHFileOperationW(&fileop);
|
||||
return (ret == 0);
|
||||
}
|
||||
|
||||
bool platform_lock_single_instance()
|
||||
{
|
||||
HANDLE mutex, status;
|
||||
|
||||
@@ -89,7 +89,6 @@ void platform_refresh_video(bool recreate_window);
|
||||
// Platform specific definitions
|
||||
time_t platform_file_get_modified_time(const utf8* path);
|
||||
bool platform_ensure_directory_exists(const utf8* path);
|
||||
bool platform_directory_delete(const utf8* path);
|
||||
std::string platform_get_absolute_path(const utf8* relative_path, const utf8* base_path);
|
||||
bool platform_lock_single_instance();
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace TitleSequenceManager
|
||||
}
|
||||
else
|
||||
{
|
||||
platform_directory_delete(path);
|
||||
Path::DeleteDirectory(path);
|
||||
}
|
||||
_items.erase(_items.begin() + i);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user