Disallow empty output directory
This commit is contained in:
parent
e1873ad576
commit
f9f27de91c
@ -1011,7 +1011,14 @@ int main(int argCount, const char* argv[])
|
|||||||
if (longCommandWArg(&argument, "--stream-size=")) { streamSrcSize = readSizeTFromChar(&argument); continue; }
|
if (longCommandWArg(&argument, "--stream-size=")) { streamSrcSize = readSizeTFromChar(&argument); continue; }
|
||||||
if (longCommandWArg(&argument, "--target-compressed-block-size=")) { targetCBlockSize = readSizeTFromChar(&argument); continue; }
|
if (longCommandWArg(&argument, "--target-compressed-block-size=")) { targetCBlockSize = readSizeTFromChar(&argument); continue; }
|
||||||
if (longCommandWArg(&argument, "--size-hint=")) { srcSizeHint = readSizeTFromChar(&argument); continue; }
|
if (longCommandWArg(&argument, "--size-hint=")) { srcSizeHint = readSizeTFromChar(&argument); continue; }
|
||||||
if (longCommandWArg(&argument, "--output-dir-flat")) { NEXT_FIELD(outDirName); continue; }
|
if (longCommandWArg(&argument, "--output-dir-flat")) {
|
||||||
|
NEXT_FIELD(outDirName);
|
||||||
|
if (strlen(outDirName) == 0) {
|
||||||
|
DISPLAY("error: output dir cannot be empty string (did you mean to pass '.' instead?)\n");
|
||||||
|
CLEAN_RETURN(1);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (longCommandWArg(&argument, "--auto-threads")) {
|
if (longCommandWArg(&argument, "--auto-threads")) {
|
||||||
const char* threadDefault = NULL;
|
const char* threadDefault = NULL;
|
||||||
NEXT_FIELD(threadDefault);
|
NEXT_FIELD(threadDefault);
|
||||||
@ -1020,7 +1027,14 @@ int main(int argCount, const char* argv[])
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#ifdef UTIL_HAS_MIRRORFILELIST
|
#ifdef UTIL_HAS_MIRRORFILELIST
|
||||||
if (longCommandWArg(&argument, "--output-dir-mirror")) { NEXT_FIELD(outMirroredDirName); continue; }
|
if (longCommandWArg(&argument, "--output-dir-mirror")) {
|
||||||
|
NEXT_FIELD(outMirroredDirName);
|
||||||
|
if (strlen(outMirroredDirName) == 0) {
|
||||||
|
DISPLAY("error: output dir cannot be empty string (did you mean to pass '.' instead?)\n");
|
||||||
|
CLEAN_RETURN(1);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifndef ZSTD_NOTRACE
|
#ifndef ZSTD_NOTRACE
|
||||||
if (longCommandWArg(&argument, "--trace")) { char const* traceFile; NEXT_FIELD(traceFile); TRACE_enable(traceFile); continue; }
|
if (longCommandWArg(&argument, "--trace")) { char const* traceFile; NEXT_FIELD(traceFile); TRACE_enable(traceFile); continue; }
|
||||||
|
7
tests/cli-tests/basic/output_dir.sh
Executable file
7
tests/cli-tests/basic/output_dir.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
println "+ zstd -r * --output-dir-mirror=\"\""
|
||||||
|
zstd -r * --output-dir-mirror="" && die "Should not allow empty output dir!"
|
||||||
|
println "+ zstd -r * --output-dir-flat=\"\""
|
||||||
|
zstd -r * --output-dir-flat="" && die "Should not allow empty output dir!"
|
||||||
|
exit 0
|
2
tests/cli-tests/basic/output_dir.sh.stderr.exact
Normal file
2
tests/cli-tests/basic/output_dir.sh.stderr.exact
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
error: output dir cannot be empty string (did you mean to pass '.' instead?)
|
||||||
|
error: output dir cannot be empty string (did you mean to pass '.' instead?)
|
2
tests/cli-tests/basic/output_dir.sh.stdout.exact
Normal file
2
tests/cli-tests/basic/output_dir.sh.stdout.exact
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
+ zstd -r * --output-dir-mirror=""
|
||||||
|
+ zstd -r * --output-dir-flat=""
|
Loading…
x
Reference in New Issue
Block a user