sdbd-demo.git

git clone https://git.crispbyte.dev/sdbd-demo.git

commit
b7ebbd9
parent
ec0e0ec
author
CheddarCrisp
date
2024-01-10 03:51:31 +0100 CET
Account for a file path
1 files changed,  +7, -6
M SDBD.Demo/Program.cs
+7, -6
 1@@ -1,7 +1,8 @@
 2 SDBD.ICodec codec = new SDBD.Codec();
 3 
 4-var (encode, filename) = ParseArgs(args);
 5-var inputData = File.ReadAllBytes(filename);
 6+var (encode, filepath) = ParseArgs(args);
 7+var inputData = File.ReadAllBytes(filepath);
 8+var filename = Path.GetFileName(filepath);
 9 
10 if(encode) {
11   SDBD.Document document = new (
12@@ -17,11 +18,11 @@ if(encode) {
13   File.WriteAllBytes(document.Metadata["content-name"], document.Data);
14 }
15 
16-(bool encode, string filename) ParseArgs(string[] args) {
17+(bool encode, string filepath) ParseArgs(string[] args) {
18   return args switch {
19-    [var filename] => (true, filename),
20-    ["-d", var filename] => (false, filename),
21-    ["-e", var filename] => (true, filename),
22+    [var filepath] => (true, filepath),
23+    ["-d", var filepath] => (false, filepath),
24+    ["-e", var filepath] => (true, filepath),
25     _ => throw new Exception("I don't like those arguments")
26   };
27 }