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);
|
||||
Version.TryParse(productVersion, out var version);
|
||||
return SemanticVersion.Parse(version.ToString(3));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -2,8 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using Vestris.ResourceLib;
|
||||
|
||||
namespace KattekerCreator.Helper
|
||||
|
@ -54,6 +54,7 @@
|
||||
<Compile Include="IconExtractor\IconExtractor.cs" />
|
||||
<Compile Include="IconExtractor\IconUtil.cs" />
|
||||
<Compile Include="IconExtractor\NativeMethods.cs" />
|
||||
<Compile Include="PathFragments.cs" />
|
||||
<Compile Include="PhysicalFile.cs" />
|
||||
<Compile Include="Program.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 PhysicalFile(string sourcePath, string targetPath)
|
||||
public PhysicalFile(string source, string target)
|
||||
{
|
||||
SourcePath = sourcePath;
|
||||
TargetPath = targetPath;
|
||||
Source = source;
|
||||
Target = target;
|
||||
}
|
||||
|
||||
public string SourcePath { get; }
|
||||
public string TargetPath { get; }
|
||||
public string Source { get; }
|
||||
public string Target { get; }
|
||||
}
|
||||
}
|
@ -30,55 +30,21 @@ namespace KattekerCreator
|
||||
public string UninstallIcon { 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 IEnumerable<string> DirectoriesToCreate()
|
||||
{
|
||||
foreach (var physicalFile in Files)
|
||||
{
|
||||
var dirSplit = new DirSplit(physicalFile.TargetPath);
|
||||
if (dirSplit.SplitCount > 1 && !_directoriesList.Contains(dirSplit))
|
||||
var dirSplit = new PathFragments(physicalFile.Target);
|
||||
if (dirSplit.FragmentLength > 1 && !_directoriesList.Contains(dirSplit))
|
||||
{
|
||||
_directoriesList.Add(dirSplit);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
return _directoriesList.Select(x => x.ToString());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Katteker.Gui.Properties;
|
||||
|
Loading…
x
Reference in New Issue
Block a user