41 lines
1.5 KiB
C#
41 lines
1.5 KiB
C#
using System.ComponentModel;
|
|
using TeaBox.Macros;
|
|
using TeaBox.SourceControl;
|
|
using System.IO;
|
|
using JD.Asset.Types.Map;
|
|
|
|
|
|
namespace TeaBox.TechCellToolbox
|
|
{
|
|
[Module, Category(@"Data\TechCell ToolBox"), DisplayName("Various Tools")]
|
|
class findFile
|
|
{
|
|
[Macro]
|
|
[Description("find text in map datas")]
|
|
private static void ContentFinder(IExecutionContext context, MapList maps,
|
|
[Description("define in which file the text will be looked for")]string fileFilter,
|
|
[Description("define if the result files would be including or missing the text")]bool include,
|
|
[Description("reference text")]string text)
|
|
{
|
|
Changelist changelist;
|
|
SourceControlService.Instance.Data()
|
|
.CreateChangelist("[Teabox]Found Files", out changelist);
|
|
var perforceCommandContext = new CommandExecutionContext(context, changelist);
|
|
foreach (var map in maps)
|
|
{
|
|
var files = System.IO.Directory.GetFiles(map.Folder, fileFilter, SearchOption.AllDirectories);
|
|
foreach (var file in files)
|
|
{
|
|
if (System.IO.File.ReadAllText(file).Contains(text) == include)
|
|
{
|
|
context.LogWarning($@"result -> {map.Name}");
|
|
SourceControlService.Instance.Data()
|
|
.Checkout(perforceCommandContext, new[] {PathEntry.FromFile(file)});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|