Skip to content

Commit

Permalink
Updated subfolders to handle folders as well
Browse files Browse the repository at this point in the history
  • Loading branch information
daredloco committed Oct 30, 2020
1 parent f7750e9 commit d8d1da1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
4 changes: 2 additions & 2 deletions GitInstaller/GitInstaller/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.6.0.0")]
[assembly: AssemblyFileVersion("1.6.0.0")]
[assembly: AssemblyVersion("1.6.1.0")]
[assembly: AssemblyFileVersion("1.6.1.0")]
16 changes: 16 additions & 0 deletions GitInstaller/GitInstaller/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,27 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace GitInstaller
{
public static class Utils
{
public enum ZipType
{
File,
Directory,
None
}

public static ZipType FileOrDir(string path)
{
if (path.EndsWith("/"))
return ZipType.Directory;
else
return ZipType.File;
}

public static bool HasWildcard(string value, string wildcard, string wildcardchar = "*")
{

Expand Down
12 changes: 10 additions & 2 deletions GitInstaller/GitInstaller/ZipSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ public ZipSettings() { }

public string GetSubfolder(string fname, string sub = "")
{
SubFolder sf = Subfolders.Find(x => x.Files.Find(y => y == fname) != null);
SubFolder sf = null;
string ffolder = fname.Replace(fname.Split('/')[fname.Split('/').Length - 1], "").Replace(fname.Split('\\')[fname.Split('\\').Length - 1],"");
sf = Subfolders.Find(x => x.Directories.Find(y => y == ffolder) != null);
sf = Subfolders.Find(x => x.Files.Find(y => y == fname) != null);
if (sf == null)
return "";

Expand Down Expand Up @@ -52,7 +55,11 @@ public static ZipSettings FromStream(Stream stream)
sub.Name = dict.Key;
foreach (JToken token in dict.Value.Children<JToken>().ToList())
{
sub.Files.Add(token.Value<string>());
Utils.ZipType ztype = Utils.FileOrDir(token.Value<string>());
if (ztype == Utils.ZipType.File)
sub.Files.Add(token.Value<string>());
else if (ztype == Utils.ZipType.Directory)
sub.Directories.Add(token.Value<string>());
}
}
zs.Subfolders.Add(sub);
Expand All @@ -71,6 +78,7 @@ public class SubFolder
{
public string Name;
public List<string> Files = new List<string>();
public List<string> Directories = new List<string>();
}
}
}

0 comments on commit d8d1da1

Please sign in to comment.