mirror of
https://github.com/zxing/zxing.git
synced 2025-01-12 19:57:27 -08:00
Closes issue #540 : handle file paths with space
This commit is contained in:
parent
1eaa66dbfa
commit
3b4fc7a244
|
@ -19,6 +19,7 @@ package com.google.zxing.client.j2se;
|
|||
import com.beust.jcommander.JCommander;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.DirectoryStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
@ -55,7 +56,21 @@ public final class CommandLineRunner {
|
|||
return;
|
||||
}
|
||||
|
||||
List<URI> inputs = config.inputPaths;
|
||||
List<URI> inputs = new ArrayList<>(config.inputPaths.size());
|
||||
for (String inputPath : config.inputPaths) {
|
||||
URI uri;
|
||||
try {
|
||||
uri = new URI(inputPath);
|
||||
} catch (URISyntaxException use) {
|
||||
// Assume it must be a file
|
||||
if (!Files.exists(Paths.get(inputPath))) {
|
||||
throw use;
|
||||
}
|
||||
uri = new URI("file", inputPath, null);
|
||||
}
|
||||
inputs.add(uri);
|
||||
}
|
||||
|
||||
do {
|
||||
inputs = retainValid(expand(inputs), config.recursive);
|
||||
} while (config.recursive && isExpandable(inputs));
|
||||
|
|
|
@ -21,7 +21,6 @@ import com.beust.jcommander.validators.PositiveInteger;
|
|||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.DecodeHintType;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
@ -80,7 +79,7 @@ final class DecoderConfig {
|
|||
boolean help;
|
||||
|
||||
@Parameter(description = "(URIs to decode)", required = true, variableArity = true)
|
||||
List<URI> inputPaths;
|
||||
List<String> inputPaths;
|
||||
|
||||
Map<DecodeHintType,?> buildHints() {
|
||||
List<BarcodeFormat> finalPossibleFormats = possibleFormats;
|
||||
|
|
Loading…
Reference in a new issue