mirror of
https://github.com/AssetRipper/AssetRipper.git
synced 2025-12-11 20:15:29 +01:00
Disallow exporting to Desktop, Documents, and Downloads
This commit is contained in:
parent
ab928a7f5b
commit
b5b9c2bc94
@ -51,7 +51,7 @@ public static class GameFileLoader
|
||||
|
||||
public static void ExportUnityProject(string path)
|
||||
{
|
||||
if (IsLoaded)
|
||||
if (IsLoaded && IsValidExportDirectory(path))
|
||||
{
|
||||
Directory.Delete(path, true);
|
||||
Directory.CreateDirectory(path);
|
||||
@ -61,7 +61,7 @@ public static class GameFileLoader
|
||||
|
||||
public static void ExportPrimaryContent(string path)
|
||||
{
|
||||
if (IsLoaded)
|
||||
if (IsLoaded && IsValidExportDirectory(path))
|
||||
{
|
||||
Directory.Delete(path, true);
|
||||
Directory.CreateDirectory(path);
|
||||
@ -79,4 +79,20 @@ public static class GameFileLoader
|
||||
settings.LoadFromDefaultPath();
|
||||
return settings;
|
||||
}
|
||||
|
||||
private static bool IsValidExportDirectory(string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
Logger.Error(LogCategory.Export, "Export path is empty");
|
||||
return false;
|
||||
}
|
||||
string directoryName = Path.GetFileName(path);
|
||||
if (directoryName is "Desktop" or "Documents" or "Downloads")
|
||||
{
|
||||
Logger.Error(LogCategory.Export, $"Export path '{path}' is a system directory");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user