-
Notifications
You must be signed in to change notification settings - Fork 116
Add strip path prefix while grouping by container, and add filter exclude mode #113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: AssetStudioMod
Are you sure you want to change the base?
Changes from all commits
aa57688
de96752
5bd31db
d41c9cd
0a763c5
3d5fb9d
1ac2276
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -637,6 +637,14 @@ private static void FilterAssets() | |||||||||
| ); | ||||||||||
| break; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| if (CLIOptions.f_filterExcludeMode.Value) | ||||||||||
| { | ||||||||||
| var excludeCount = assetsCount - filteredAssets.Count; | ||||||||||
| Logger.Info($"Excluding {excludeCount} asset(s) that match the filter."); | ||||||||||
| filteredAssets = parsedAssetsList.Except(filteredAssets).ToList(); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| parsedAssetsList.Clear(); | ||||||||||
| parsedAssetsList = filteredAssets; | ||||||||||
| } | ||||||||||
|
|
@@ -651,6 +659,31 @@ public static void ExportAssets() | |||||||||
| var parallelExportCount = CLIOptions.o_maxParallelExportTasks.Value; | ||||||||||
| var toExportAssetDict = new ConcurrentDictionary<AssetItem, string>(); | ||||||||||
| var toParallelExportAssetDict = new ConcurrentDictionary<AssetItem, string>(); | ||||||||||
|
|
||||||||||
| if (CLIOptions.o_stripPathPrefix.Value != null) | ||||||||||
|
||||||||||
| { | ||||||||||
| foreach (var asset in parsedAssetsList) | ||||||||||
| { | ||||||||||
| var containerPath = asset.Container; | ||||||||||
| if (string.IsNullOrEmpty(containerPath)) | ||||||||||
| { | ||||||||||
| continue; | ||||||||||
| } | ||||||||||
| if (!Path.Combine(Path.GetDirectoryName(containerPath), Path.GetFileName(containerPath)).StartsWith(CLIOptions.o_stripPathPrefix.Value)) | ||||||||||
|
||||||||||
| if (!Path.Combine(Path.GetDirectoryName(containerPath), Path.GetFileName(containerPath)).StartsWith(CLIOptions.o_stripPathPrefix.Value)) | |
| if (!containerPath.StartsWith(CLIOptions.o_stripPathPrefix.Value)) |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same null check pattern issue as line 663. This should use !string.IsNullOrEmpty() for consistency with the rest of the codebase, or the default value should be changed to null.
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same null check pattern issue as lines 663 and 682. This should use !string.IsNullOrEmpty() for consistency with the rest of the codebase.
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Substring operation could throw an ArgumentOutOfRangeException if containerPath is shorter than the prefix length. While the validation loop above attempts to prevent this, it uses a different logic (Path.Combine with GetDirectoryName/GetFileName) that may not guarantee the same result. Add a length check here: if (containerPath.Length >= CLIOptions.o_stripPathPrefix.Value.Length) before calling Substring, or ensure the validation logic matches exactly.
| if (CLIOptions.o_stripPathPrefix.Value != null) | |
| if (CLIOptions.o_stripPathPrefix.Value != null && | |
| !string.IsNullOrEmpty(containerPath) && | |
| containerPath.Length >= CLIOptions.o_stripPathPrefix.Value.Length) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Path.Combine(Path.GetDirectoryName(value), Path.GetFileName(value)) to normalize the path is problematic. This approach may fail for edge cases: (1) If value is a root path like "C:", GetDirectoryName returns null; (2) If value has a trailing separator, it will be removed; (3) If value is just a filename with no directory, GetDirectoryName returns empty string and Combine will just return the filename. Consider using Path.GetFullPath(value) for proper path normalization, or simply use the value as-is and let the validation in Studio.cs handle the format checking.