Update ArchiveManager and themes

This commit is contained in:
Adison Cavani 2021-12-30 22:42:19 +01:00
parent ad68cbb47a
commit 138b1fa224
No known key found for this signature in database
GPG key ID: E823B50BB3E2472D
36 changed files with 19 additions and 45 deletions

View file

@ -1,39 +1,15 @@
using System; using ICSharpCode.SharpZipLib.Tar;
using System;
using System.IO;
namespace DistroGrubThemes namespace DistroGrubThemes
{ {
public class ArchiveManager public static class ArchiveManager
{ {
public static void CreateTarArchive(string sourceDirectory, string outputFile, bool verbose) public static void CreateTarArchive(string outputFile, bool verbose)
{ {
Chilkat.Tar tar = new Chilkat.Tar Stream outStream = File.Create(outputFile);
{ TarArchive.CreateOutputTarArchive(outStream);
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;
}
if (verbose) if (verbose)
{ {

View file

@ -8,8 +8,8 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ChilkatDnCore" Version="9.5.0.88" />
<PackageReference Include="CommandLineParser" Version="2.8.0" /> <PackageReference Include="CommandLineParser" Version="2.8.0" />
<PackageReference Include="SharpZipLib" Version="1.3.3" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -21,16 +21,14 @@ namespace DistroGrubThemes
string path = program.CheckRepoPath(opts.RepositoryPath); string path = program.CheckRepoPath(opts.RepositoryPath);
if (opts.UpdateFonts) if (opts.UpdateFonts)
{ program.UpdateFonts($"{path}\\font", $"{path}\\customize", opts.VerboseMode);
program.UpdateFonts(path + @"\font", path + @"\customize", opts.VerboseMode);
}
if (opts.UpdateIcons) if (opts.UpdateIcons)
{ {
if (opts.VerboseMode) if (opts.VerboseMode)
Console.WriteLine(); Console.WriteLine();
program.UpdateIcons(path + @"\assets\icons", path + @"\customize", opts.VerboseMode); program.UpdateIcons($"{path}\\assets\\icons", $"{path}\\customize", opts.VerboseMode);
} }
if (opts.UpdateArchives) if (opts.UpdateArchives)
@ -47,12 +45,12 @@ namespace DistroGrubThemes
if (!verbose) if (!verbose)
Console.Write("Creating .tar archives ... "); Console.Write("Creating .tar archives ... ");
foreach (var directory in DirectoriesDictionary(path + @"\customize", path)) foreach (var directory in DirectoriesDictionary($"{path}\\customize", path))
{ {
if (verbose) if (verbose)
Console.Write("Creating " + directory.Value + ".tar archive ... "); Console.Write($"Creating {directory.Value}.tar archive ... ");
ArchiveManager.CreateTarArchive(directory.Key, path + @"\themes\" + directory.Value + ".tar", verbose); ArchiveManager.CreateTarArchive($"{path}\\themes\\{directory.Value}.tar", verbose);
} }
if (!verbose) if (!verbose)
@ -73,9 +71,9 @@ namespace DistroGrubThemes
foreach (var icon in FilesArray(iconsPath)) foreach (var icon in FilesArray(iconsPath))
{ {
if (verbose) if (verbose)
Console.Write("Copying " + icon + " ... "); Console.Write($"Copying {icon} ... ");
File.Copy(iconsPath + @"\" + icon, directory + @"\icons\" + icon, true); File.Copy($"{iconsPath}\\{icon}", $"{directory}\\icons\\{icon}", true);
if (verbose) if (verbose)
{ {
@ -104,9 +102,9 @@ namespace DistroGrubThemes
foreach (var font in FilesArray(fontsPath)) foreach (var font in FilesArray(fontsPath))
{ {
if (verbose) if (verbose)
Console.Write("Copying " + font + " ... "); Console.Write($"Copying {font} ... ");
File.Copy(fontsPath + @"\" + font, directory + @"\" + font, true); File.Copy($"{fontsPath}\\{font}", $"{directory}\\{font}", true);
if (verbose) if (verbose)
{ {
@ -139,7 +137,7 @@ namespace DistroGrubThemes
{ {
var dirsArray = Directory.GetDirectories(directoryPath); var dirsArray = Directory.GetDirectories(directoryPath);
return dirsArray.ToDictionary(key => key, value => value.Substring(value.IndexOf(@"customize\") + 10)); return dirsArray.ToDictionary(key => key, value => value[(value.IndexOf(@"customize\") + 10)..]);
} }
string CheckRepoPath(string path) string CheckRepoPath(string path)
@ -147,7 +145,7 @@ namespace DistroGrubThemes
if (Directory.Exists(path) && path.Contains("distro-grub-themes")) if (Directory.Exists(path) && path.Contains("distro-grub-themes"))
{ {
int index = path.IndexOf("distro-grub-themes") + 18; int index = path.IndexOf("distro-grub-themes") + 18;
return path.Substring(0, index); return path[..index];
} }
else else

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

0
themes/mate.tar Normal file
View file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.