From 472cf1f210757f1ba613add5888137cf1be65d6c Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Tue, 6 Dec 2022 17:19:28 +0100 Subject: [PATCH] Made `IsSubPCKNode` more flexible --- PCK-Studio/MainForm.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index 6623af99..6ba1582a 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -828,18 +828,17 @@ namespace PckStudio } } - bool IsSubPCKNode(string nodePath) + bool IsSubPCKNode(string nodePath, string extention = ".pck") { // written by miku, implemented and modified by me - MNL + if (nodePath.EndsWith(extention)) return false; + string[] subpaths = nodePath.Split('/'); - string[] conditions = subpaths.Select(s => Path.GetExtension(s) switch { - ".pck" => "yes", - _ => "no", - }).ToArray(); + var conditions = subpaths.Select(s => Path.GetExtension(s).Equals(extention)); - bool isSubFile = conditions.Contains("yes") && !nodePath.EndsWith(".pck"); + bool isSubFile = conditions.Contains(true); - Console.WriteLine(nodePath + " is " + (isSubFile ? "" : "not ") + "a Sub-PCK File"); + Console.WriteLine($"{nodePath} is{(isSubFile ? "" : " not")} a Sub-PCK File"); return isSubFile; }