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
{
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
{
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;
}
Stream outStream = File.Create(outputFile);
TarArchive.CreateOutputTarArchive(outStream);
if (verbose)
{

View file

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

View file

@ -21,16 +21,14 @@ namespace DistroGrubThemes
string path = program.CheckRepoPath(opts.RepositoryPath);
if (opts.UpdateFonts)
{
program.UpdateFonts(path + @"\font", path + @"\customize", opts.VerboseMode);
}
program.UpdateFonts($"{path}\\font", $"{path}\\customize", opts.VerboseMode);
if (opts.UpdateIcons)
{
if (opts.VerboseMode)
Console.WriteLine();
program.UpdateIcons(path + @"\assets\icons", path + @"\customize", opts.VerboseMode);
program.UpdateIcons($"{path}\\assets\\icons", $"{path}\\customize", opts.VerboseMode);
}
if (opts.UpdateArchives)
@ -47,12 +45,12 @@ namespace DistroGrubThemes
if (!verbose)
Console.Write("Creating .tar archives ... ");
foreach (var directory in DirectoriesDictionary(path + @"\customize", path))
foreach (var directory in DirectoriesDictionary($"{path}\\customize", path))
{
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)
@ -73,9 +71,9 @@ namespace DistroGrubThemes
foreach (var icon in FilesArray(iconsPath))
{
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)
{
@ -104,9 +102,9 @@ namespace DistroGrubThemes
foreach (var font in FilesArray(fontsPath))
{
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)
{
@ -139,7 +137,7 @@ namespace DistroGrubThemes
{
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)
@ -147,7 +145,7 @@ namespace DistroGrubThemes
if (Directory.Exists(path) && path.Contains("distro-grub-themes"))
{
int index = path.IndexOf("distro-grub-themes") + 18;
return path.Substring(0, index);
return path[..index];
}
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.