diff --git a/src/ArchiveManager.cs b/src/ArchiveManager.cs
new file mode 100644
index 0000000..903b78b
--- /dev/null
+++ b/src/ArchiveManager.cs
@@ -0,0 +1,39 @@
+using System;
+
+namespace DistroGrubThemes
+{
+ public class ArchiveManager
+ {
+ public static void CreateTarArchive(string sourceDirectory, string outputFile)
+ {
+ Chilkat.Tar tar = new Chilkat.Tar
+ {
+ WriteFormat = "gnu"
+ };
+
+ // Add a directory tree to be included in the output TAR archive:
+ bool success = tar.AddDirRoot(sourceDirectory);
+ if (success != true)
+ {
+ Console.ForegroundColor = ConsoleColor.Red;
+ Console.Write("ERROR\n\n");
+ Console.Write("error: ");
+ Console.ResetColor();
+ Console.Write(tar.LastErrorText + "\n");
+ return;
+ }
+
+ // Create the TAR archive.
+ success = tar.WriteTar(outputFile);
+ if (success != true)
+ {
+ Console.ForegroundColor = ConsoleColor.Red;
+ Console.Write("ERROR\n\n");
+ Console.Write("error: ");
+ Console.ResetColor();
+ Console.Write(tar.LastErrorText + "\n");
+ return;
+ }
+ }
+ }
+}
diff --git a/src/DistroGrubThemes.csproj b/src/DistroGrubThemes.csproj
index b132f8d..6b12645 100644
--- a/src/DistroGrubThemes.csproj
+++ b/src/DistroGrubThemes.csproj
@@ -8,8 +8,8 @@
+
-
diff --git a/src/Program.cs b/src/Program.cs
index 7b62eed..b745cbf 100644
--- a/src/Program.cs
+++ b/src/Program.cs
@@ -1,6 +1,7 @@
using CommandLine;
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.IO;
using System.Linq;
@@ -18,8 +19,25 @@ namespace DistroGrubThemes
static void RunOptions(ProgramOptions opts)
{
Program program = new Program();
+
string path = program.CheckRepoPath(opts.RepositoryPath);
+
program.UpdateAssets(path);
+ Console.WriteLine();
+ program.UpdateArchive(path);
+ }
+
+ void UpdateArchive(string path)
+ {
+ foreach (var directory in DirectoriesDictionary(path + @"\customize", path))
+ {
+ Console.Write("Creating " + directory.Value + ".tar archive ... ");
+ ArchiveManager.CreateTarArchive(directory.Key, path + @"\themes\" + directory.Value + ".tar");
+
+ Console.ForegroundColor = ConsoleColor.Green;
+ Console.Write("OK\n");
+ Console.ResetColor();
+ }
}
void UpdateAssets(string path)
@@ -33,7 +51,7 @@ namespace DistroGrubThemes
Console.Write("\nUpdating icons ... ");
var icons = FilesArray(iconsPath);
- foreach (var directory in CustomDirectories(customizePath))
+ foreach (var directory in DirectoriesArray(customizePath))
{
foreach (var icon in icons)
{
@@ -51,7 +69,7 @@ namespace DistroGrubThemes
Console.Write("Updating fonts ... ");
var fonts = FilesArray(fontsPath);
- foreach (var directory in CustomDirectories(customizePath))
+ foreach (var directory in DirectoriesArray(customizePath))
{
foreach (var font in fonts)
{
@@ -69,9 +87,16 @@ namespace DistroGrubThemes
return new List(Directory.GetFiles(folderPath).Select(Path.GetFileName));
}
- string[] CustomDirectories(string customizePath)
+ string[] DirectoriesArray(string directoryPath)
{
- return Directory.GetDirectories(customizePath);
+ return Directory.GetDirectories(directoryPath);
+ }
+
+ Dictionary DirectoriesDictionary(string directoryPath, string repoPath)
+ {
+ var dirsArray = Directory.GetDirectories(directoryPath);
+
+ return dirsArray.ToDictionary(key => key, value => value.Substring(value.IndexOf(@"customize\") + 10));
}
string CheckRepoPath(string path)