cleanup
This commit is contained in:
@@ -331,6 +331,30 @@ namespace SplashEdit.RuntimeCode
|
||||
{
|
||||
private static int MaxTextureSize => 256;
|
||||
|
||||
/// <summary>
|
||||
/// If a directory contains exactly one subdirectory (common after archive extraction),
|
||||
/// flatten its contents up one level and remove the nested directory.
|
||||
/// </summary>
|
||||
public static void FixNestedDirectory(string dir)
|
||||
{
|
||||
var subdirs = System.IO.Directory.GetDirectories(dir);
|
||||
if (subdirs.Length == 1)
|
||||
{
|
||||
string nested = subdirs[0];
|
||||
foreach (string file in System.IO.Directory.GetFiles(nested))
|
||||
{
|
||||
string dest = System.IO.Path.Combine(dir, System.IO.Path.GetFileName(file));
|
||||
if (!System.IO.File.Exists(dest)) System.IO.File.Move(file, dest);
|
||||
}
|
||||
foreach (string sub in System.IO.Directory.GetDirectories(nested))
|
||||
{
|
||||
string dest = System.IO.Path.Combine(dir, System.IO.Path.GetFileName(sub));
|
||||
if (!System.IO.Directory.Exists(dest)) System.IO.Directory.Move(sub, dest);
|
||||
}
|
||||
try { System.IO.Directory.Delete(nested, true); } catch { }
|
||||
}
|
||||
}
|
||||
|
||||
public static (Rect, Rect) BufferForResolution(Vector2 selectedResolution, bool verticalLayout, Vector2 offset = default)
|
||||
{
|
||||
if (offset == default)
|
||||
|
||||
Reference in New Issue
Block a user