mirror of
https://github.com/chylex/Brotli-Builder.git
synced 2025-08-18 18:24:55 +02:00
BrotliBuilder
BrotliCalc
Commands
Base
CmdBenchReserializeRebuild.cs
CmdCompress.cs
CmdCompressStats.cs
CmdCopyUncompressed.cs
CmdEncode.cs
CmdExtractBlockTypes.cs
CmdExtractContextMaps.cs
CmdExtractDistanceContextInfo.cs
CmdExtractHeaderMeta.cs
CmdExtractInsertCopyStats.cs
CmdExtractWindowSize.cs
CmdGenerateMarkers.cs
CmdGenerateOfficialDictionaryHashLookup.cs
CmdGenerateOfficialDictionaryHashLookup2.cs
CmdRebuild.cs
CmdReserialize.cs
CmdReserializeCountBitsContextMaps.cs
CmdTestEncoder.cs
CmdTestRebuild.cs
CmdTestReserialize.cs
CmdTestTransformer.cs
CmdTimeDictionaryIndex.cs
CmdTransform.cs
CmdValidateCompression.cs
CmdValidateQuality0.cs
Helpers
Properties
Resources
Arguments.cs
BrotliCalc.csproj
Parameters.cs
Program.cs
BrotliImpl
BrotliLib
Paper
UnitTests
.gitignore
BrotliBuilder.sln
LICENSE
README.md
45 lines
1.7 KiB
C#
45 lines
1.7 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Text;
|
|
using BrotliCalc.Commands.Base;
|
|
using BrotliCalc.Helpers;
|
|
using BrotliLib.Markers;
|
|
|
|
namespace BrotliCalc.Commands{
|
|
class CmdGenerateMarkers : CmdAbstractFileMapper.Compressed{
|
|
public override string FullName => "generate-markers";
|
|
public override string ShortName => "gm";
|
|
|
|
protected override int ExtraArgumentCount => 2;
|
|
protected override string ExtraArgumentDesc => "<s|simple|v|verbose> <includeBitCounts>";
|
|
|
|
protected override string WorkDesc => "Extracted markers from";
|
|
protected override string AppendFileName => ".txt";
|
|
|
|
private MarkerLevel markerLevel;
|
|
private bool includeBitCounts;
|
|
|
|
protected override void Setup(string[] args){
|
|
markerLevel = args[0] switch{
|
|
var x when x == "s" || x == "simple" => MarkerLevel.Simple,
|
|
var x when x == "v" || x == "verbose" => MarkerLevel.Verbose,
|
|
_ => throw new ArgumentException("Invalid marker type: " + args[0])
|
|
};
|
|
|
|
includeBitCounts = args[1] switch{
|
|
var x when x == "y" || x == "yes" || x == "true" => true,
|
|
var x when x == "n" || x == "no" || x == "false" => false,
|
|
_ => throw new ArgumentException("Invalid includeBitCounts value: " + args[1])
|
|
};
|
|
}
|
|
|
|
protected override void MapFile(BrotliFileGroup group, BrotliFile.Compressed file, FileStream output){
|
|
using var stream = new StreamWriter(output, Encoding.UTF8){
|
|
NewLine = "\n"
|
|
};
|
|
|
|
file.WriteMarkers(stream, includeBitCounts, markerLevel);
|
|
}
|
|
}
|
|
}
|