Skip to content

Commit

Permalink
优化写入 stdout 时的预判断逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
lc6464 committed Mar 4, 2024
1 parent 845cd37 commit 5711768
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,15 @@ 4. 编解码失败

if (writeToStdout) { // Write to stdout

return File.Exists(args[1])
? Helpers.WriteToStdOut(isEncodeMode ? Base16384.EncodeFromFileToStream : Base16384.DecodeFromFileToStream,
new FileInfo(args[1]))
: Helpers.PrintErrorMessage(null, "Source file not found.", 2);
if (args[1].Contains(',')) {
return Helpers.PrintErrorMessage(null, "Source file cannot be a list when writing to stdout.", 2);
}

if (!File.Exists(args[1])) {
return Helpers.PrintErrorMessage(null, "Source file not found.", 2);
}

return Helpers.WriteToStdOut(isEncodeMode ? Base16384.EncodeFromFileToStream : Base16384.DecodeFromFileToStream, new FileInfo(args[1]));
}


Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Base16384.Net <"e" | "d"> <source | "-"> [out | "-"]
- 输入为标准输入时,结果输出到标准输出
- 输入为文件时,结果写入 `源文件名.encoded` 或 `源文件名.decoded`
- 输入为文件夹或逗号分隔的文件列表时,结果写入到 `encoded` 或 `decoded` 文件夹内相应结构的文件内
- `-` 表示输出到标准输出,输入为文件夹时无效
- `-` 表示输出到标准输出,输入为文件夹或逗号分隔的文件列表时无效
- 其他
- 输入为文件时,输出到指定文件
- 输入为文件夹或逗号分隔的文件列表时,输出到指定文件夹
Expand Down

0 comments on commit 5711768

Please sign in to comment.