Skip to content

Commit

Permalink
实现编码文件部分
Browse files Browse the repository at this point in the history
  • Loading branch information
lc6464 committed Dec 7, 2023
1 parent 3e13633 commit d13c9e2
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,41 @@
// 新的解析方式:https://github.com/execute233/Base16384.Net
if (args.Length is not 2 or 3) {

if (args.Length is not 2 and not 3 || args is not ["e", ..] and not ["d", ..]) {
Console.WriteLine("Usage: Base16384.Net.exe <\"e\" | \"d\"> <source | \"-\"> [out | \"-\"]");
return 1;
}

if (args is not ["e", ..] and ["d", ..]) {
Console.WriteLine("Usage: Base16384.Net.exe <\"e\" | \"d\"> <source | \"-\"> [out | \"-\"]");
return 1;
if (args[0] == "e") {
// Encode mode
if (args[1] == "-") {
// Read from stdin
using var stdin = Console.OpenStandardInput();
if (args.Length == 2 || args[2] == "-") {
// Write to stdout
using var stdout = Console.OpenStandardOutput();
Base16384.EncodeToStream(stdin, stdout);
} else {
// Write to file
Base16384.EncodeToNewFile(stdin, new(args[2]));
}
} else {
// Read from file
if (args is [.., "-"]) {
// Write to stdout
using var stdout = Console.OpenStandardOutput();
Base16384.EncodeFromFileToStream(new(args[1]), stdout);
} else if (args.Length == 2) {
// Write to .decoded file
Base16384.EncodeFromFileToNewFile(new(args[1]), new($"{args[1]}.encoded"));
} else {
// Write to file
Base16384.EncodeFromFileToNewFile(new(args[1]), new(args[2]));
}
}
}

return 2;

return 0;


/*
Expand Down

0 comments on commit d13c9e2

Please sign in to comment.