Moved PathFragments from SetupTmplCode to extra class.
This commit is contained in:
parent
b2ef60a595
commit
016e11e81f
@ -89,7 +89,6 @@ namespace KattekerCreator
|
|||||||
return semanticVersion?.Change(build: string.Empty);
|
return semanticVersion?.Change(build: string.Empty);
|
||||||
Version.TryParse(productVersion, out var version);
|
Version.TryParse(productVersion, out var version);
|
||||||
return SemanticVersion.Parse(version.ToString(3));
|
return SemanticVersion.Parse(version.ToString(3));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,8 +2,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Security.Cryptography.X509Certificates;
|
|
||||||
using Vestris.ResourceLib;
|
using Vestris.ResourceLib;
|
||||||
|
|
||||||
namespace KattekerCreator.Helper
|
namespace KattekerCreator.Helper
|
||||||
|
@ -54,6 +54,7 @@
|
|||||||
<Compile Include="IconExtractor\IconExtractor.cs" />
|
<Compile Include="IconExtractor\IconExtractor.cs" />
|
||||||
<Compile Include="IconExtractor\IconUtil.cs" />
|
<Compile Include="IconExtractor\IconUtil.cs" />
|
||||||
<Compile Include="IconExtractor\NativeMethods.cs" />
|
<Compile Include="IconExtractor\NativeMethods.cs" />
|
||||||
|
<Compile Include="PathFragments.cs" />
|
||||||
<Compile Include="PhysicalFile.cs" />
|
<Compile Include="PhysicalFile.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
25
Creator/PathFragments.cs
Normal file
25
Creator/PathFragments.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace KattekerCreator
|
||||||
|
{
|
||||||
|
public class PathFragments
|
||||||
|
{
|
||||||
|
private readonly string[] _fragments;
|
||||||
|
|
||||||
|
public PathFragments(string path)
|
||||||
|
{
|
||||||
|
_fragments = path.Split(Path.PathSeparator);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int FragmentLength => _fragments.Length;
|
||||||
|
|
||||||
|
public override bool Equals(object obj) => string.Equals(ToString(), obj?.ToString());
|
||||||
|
|
||||||
|
public override int GetHashCode() => (_fragments != null ? _fragments.GetHashCode() : 0);
|
||||||
|
|
||||||
|
public override string ToString() => string.Join(Path.PathSeparator.ToString(), _fragments.Take(_fragments.Length - 1));
|
||||||
|
|
||||||
|
protected bool Equals(PathFragments other) => Equals(_fragments, other._fragments);
|
||||||
|
}
|
||||||
|
}
|
@ -2,13 +2,13 @@
|
|||||||
{
|
{
|
||||||
public class PhysicalFile
|
public class PhysicalFile
|
||||||
{
|
{
|
||||||
public PhysicalFile(string sourcePath, string targetPath)
|
public PhysicalFile(string source, string target)
|
||||||
{
|
{
|
||||||
SourcePath = sourcePath;
|
Source = source;
|
||||||
TargetPath = targetPath;
|
Target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string SourcePath { get; }
|
public string Source { get; }
|
||||||
public string TargetPath { get; }
|
public string Target { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -30,15 +30,15 @@ namespace KattekerCreator
|
|||||||
public string UninstallIcon { get; set; }
|
public string UninstallIcon { get; set; }
|
||||||
public string ReleaseChannel { get; set; }
|
public string ReleaseChannel { get; set; }
|
||||||
|
|
||||||
private readonly List<DirSplit> _directoriesList = new List<DirSplit>();
|
private readonly List<PathFragments> _directoriesList = new List<PathFragments>();
|
||||||
private string _appName;
|
private string _appName;
|
||||||
|
|
||||||
private IEnumerable<string> DirectoriesToCreate()
|
private IEnumerable<string> DirectoriesToCreate()
|
||||||
{
|
{
|
||||||
foreach (var physicalFile in Files)
|
foreach (var physicalFile in Files)
|
||||||
{
|
{
|
||||||
var dirSplit = new DirSplit(physicalFile.TargetPath);
|
var dirSplit = new PathFragments(physicalFile.Target);
|
||||||
if (dirSplit.SplitCount > 1 && !_directoriesList.Contains(dirSplit))
|
if (dirSplit.FragmentLength > 1 && !_directoriesList.Contains(dirSplit))
|
||||||
{
|
{
|
||||||
_directoriesList.Add(dirSplit);
|
_directoriesList.Add(dirSplit);
|
||||||
}
|
}
|
||||||
@ -46,39 +46,5 @@ namespace KattekerCreator
|
|||||||
|
|
||||||
return _directoriesList.Select(x => x.ToString());
|
return _directoriesList.Select(x => x.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DirSplit
|
|
||||||
{
|
|
||||||
private const char SplitChar = '\\';
|
|
||||||
|
|
||||||
private readonly string[] _splits;
|
|
||||||
|
|
||||||
public int SplitCount => _splits.Length;
|
|
||||||
|
|
||||||
public DirSplit(string path)
|
|
||||||
{
|
|
||||||
_splits = path.Split(SplitChar);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return string.Join(SplitChar.ToString(), _splits.Take(_splits.Length - 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
|
||||||
{
|
|
||||||
return string.Equals(ToString(), obj?.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected bool Equals(DirSplit other)
|
|
||||||
{
|
|
||||||
return Equals(_splits, other._splits);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int GetHashCode()
|
|
||||||
{
|
|
||||||
return (_splits != null ? _splits.GetHashCode() : 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Linq;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Katteker.Gui.Properties;
|
using Katteker.Gui.Properties;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user