JD2022-TU1/main/tools/apps/Packager/Tasks/ExtractOnlineMapSpecificTask.cs

38 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using JD.Core.ProjectManaging;
namespace Packager.Tasks
{
[DisplayName(@"Extract Map Specfic Dependencies for online maps")]
public class ExtractOnlineMapSpecificTask : ExtractMapSpecificTask
{
public ExtractOnlineMapSpecificTask()
{
}
public override bool ExtractMapDependencies(string mapDependencyFile, ref IEnumerable<string> mapDependencies, ref IEnumerable<string> commonDependencies)
{
try
{
//Get the dependencies from file
IEnumerable<string> dependencies = File.ReadAllLines(mapDependencyFile);
var mapFolder = DataPath.GetRelativePath(_map.MainMap.Folder).TrimEnd('\\', '/');
// Map dependencies start with the map folder
mapDependencies = dependencies.Where(d => d.StartsWith(mapFolder, StringComparison.OrdinalIgnoreCase));
commonDependencies = dependencies.Except(mapDependencies);
return true;
}
catch (Exception ex)
{
LogMessage(true, $"Exception {ex.Message} from file {mapDependencyFile}");
return false;
}
}
}
}