[CLI] Add flag to allow removing container path prefix.

- Added --strip-path-prefix flag
This commit is contained in:
middlered
2025-11-09 21:05:59 +08:00
parent aa5768850b
commit de967527ef
3 changed files with 46 additions and 2 deletions
+27 -2
View File
@@ -659,6 +659,26 @@ namespace AssetStudioCLI
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))
{
Logger.Warning($"Asset container path \"{asset.Container}\" does not start with the specified path prefix \"{CLIOptions.o_stripPathPrefix.Value}\"");
Logger.Warning("strip path prefix option will be ignored.");
CLIOptions.o_stripPathPrefix.Value = null;
break;
}
}
}
Parallel.ForEach(parsedAssetsList, asset =>
{
string exportPath;
@@ -671,7 +691,12 @@ namespace AssetStudioCLI
case AssetGroupOption.ContainerPathFull:
if (!string.IsNullOrEmpty(asset.Container))
{
exportPath = Path.Combine(savePath, Path.GetDirectoryName(asset.Container));
var containerPath = Path.GetDirectoryName(asset.Container);
if (CLIOptions.o_stripPathPrefix.Value != null)
{
containerPath = containerPath.Substring(CLIOptions.o_stripPathPrefix.Value.Length);
}
exportPath = Path.Combine(savePath, containerPath);
if (groupOption == AssetGroupOption.ContainerPathFull)
{
exportPath = Path.Combine(exportPath, Path.GetFileNameWithoutExtension(asset.Container));
@@ -740,7 +765,7 @@ namespace AssetStudioCLI
toExportAssetDict.TryAdd(asset, exportPath);
}
});
foreach (var toExportAsset in toExportAssetDict)
{
var asset = toExportAsset.Key;