mirror of
https://github.com/AdisonCavani/distro-grub-themes.git
synced 2025-06-06 07:12:33 +02:00
Fix adding files to archive, update to C# 10, update themes
This commit is contained in:
parent
138b1fa224
commit
fcb5774fe1
36 changed files with 163 additions and 132 deletions
|
@ -2,14 +2,22 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace DistroGrubThemes
|
||||
{
|
||||
namespace DistroGrubThemes;
|
||||
|
||||
public static class ArchiveManager
|
||||
{
|
||||
public static void CreateTarArchive(string outputFile, bool verbose)
|
||||
public static void CreateTarArchive(string sourceDirectory, string outputFile, bool verbose)
|
||||
{
|
||||
Stream outStream = File.Create(outputFile);
|
||||
TarArchive.CreateOutputTarArchive(outStream);
|
||||
TarArchive tarArchive = TarArchive.CreateOutputTarArchive(outStream);
|
||||
|
||||
// Case sensitive
|
||||
tarArchive.RootPath = sourceDirectory.Replace('\\', '/');
|
||||
if (tarArchive.RootPath.EndsWith("/"))
|
||||
tarArchive.RootPath = tarArchive.RootPath.Remove(tarArchive.RootPath.Length - 1);
|
||||
|
||||
AddDirectoryFilesToTar(tarArchive, sourceDirectory, true);
|
||||
tarArchive.Close();
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
|
@ -18,5 +26,28 @@ namespace DistroGrubThemes
|
|||
Console.ResetColor();
|
||||
}
|
||||
}
|
||||
|
||||
// Example: https://github.com/icsharpcode/SharpZipLib/wiki/GZip-and-Tar-Samples
|
||||
private static void AddDirectoryFilesToTar(TarArchive tarArchive, string sourceDirectory, bool recurse)
|
||||
{
|
||||
// Optionally, write an entry for the directory itself.
|
||||
// Specify false for recursion here if we will add the directory's files individually.
|
||||
TarEntry tarEntry = TarEntry.CreateEntryFromFile(sourceDirectory);
|
||||
tarArchive.WriteEntry(tarEntry, false);
|
||||
|
||||
// Write each file to the tar.
|
||||
string[] filenames = Directory.GetFiles(sourceDirectory);
|
||||
foreach (string filename in filenames)
|
||||
{
|
||||
tarEntry = TarEntry.CreateEntryFromFile(filename);
|
||||
tarArchive.WriteEntry(tarEntry, true);
|
||||
}
|
||||
|
||||
if (recurse)
|
||||
{
|
||||
string[] directories = Directory.GetDirectories(sourceDirectory);
|
||||
foreach (string directory in directories)
|
||||
AddDirectoryFilesToTar(tarArchive, directory, recurse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<Authors>Adison Cavani</Authors>
|
||||
<Company>Adison Cavani</Company>
|
||||
<LangVersion>10</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -4,8 +4,8 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace DistroGrubThemes
|
||||
{
|
||||
namespace DistroGrubThemes;
|
||||
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
|
@ -17,7 +17,7 @@ namespace DistroGrubThemes
|
|||
|
||||
static void RunOptions(ProgramOptions opts)
|
||||
{
|
||||
Program program = new Program();
|
||||
Program program = new();
|
||||
string path = program.CheckRepoPath(opts.RepositoryPath);
|
||||
|
||||
if (opts.UpdateFonts)
|
||||
|
@ -50,7 +50,7 @@ namespace DistroGrubThemes
|
|||
if (verbose)
|
||||
Console.Write($"Creating {directory.Value}.tar archive ... ");
|
||||
|
||||
ArchiveManager.CreateTarArchive($"{path}\\themes\\{directory.Value}.tar", verbose);
|
||||
ArchiveManager.CreateTarArchive(directory.Key, $"{path}\\themes\\{directory.Value}.tar", verbose);
|
||||
}
|
||||
|
||||
if (!verbose)
|
||||
|
@ -159,4 +159,3 @@ namespace DistroGrubThemes
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
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.
BIN
themes/Solus.tar
BIN
themes/Solus.tar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
themes/aorus.tar
BIN
themes/aorus.tar
Binary file not shown.
BIN
themes/arch.tar
BIN
themes/arch.tar
Binary file not shown.
BIN
themes/arco.tar
BIN
themes/arco.tar
Binary file not shown.
BIN
themes/artix.tar
BIN
themes/artix.tar
Binary file not shown.
BIN
themes/asus.tar
BIN
themes/asus.tar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
themes/hp.tar
BIN
themes/hp.tar
Binary file not shown.
Binary file not shown.
BIN
themes/mate.tar
BIN
themes/mate.tar
Binary file not shown.
BIN
themes/mint.tar
BIN
themes/mint.tar
Binary file not shown.
BIN
themes/mx.tar
BIN
themes/mx.tar
Binary file not shown.
Binary file not shown.
BIN
themes/pop.tar
BIN
themes/pop.tar
Binary file not shown.
BIN
themes/rocky.tar
BIN
themes/rocky.tar
Binary file not shown.
Binary file not shown.
BIN
themes/void.tar
BIN
themes/void.tar
Binary file not shown.
Loading…
Add table
Reference in a new issue