Issue 872 fix

This commit attempts a fix to issue 872.
The inputFileName ('master' file) parameter may be null,
in which case the function returns just the file name if short name is required.
This commit is contained in:
John Zhang
2018-01-23 11:46:02 +11:00
parent 8aeddd09a4
commit aeb554ee62

View File

@ -37,14 +37,19 @@ public class FileDataSource implements DataSource {
}
private String glomName(boolean shortNames, String inputFileName, File file) {
if (shortNames && inputFileName.indexOf(',') == -1) {
if (new File(inputFileName).isDirectory()) {
return trimAnyPathSep(file.getPath().substring(inputFileName.length()));
} else {
if (inputFileName.indexOf(FILE_SEPARATOR.charAt(0)) == -1) {
return inputFileName;
if (shortNames) {
if (inputFileName != null && inputFileName.indexOf(',') == -1) {
if (new File(inputFileName).isDirectory()) {
return trimAnyPathSep(file.getPath().substring(inputFileName.length()));
} else {
if (inputFileName.indexOf(FILE_SEPARATOR.charAt(0)) == -1) {
return inputFileName;
}
return trimAnyPathSep(inputFileName.substring(inputFileName.lastIndexOf(FILE_SEPARATOR)));
}
return trimAnyPathSep(inputFileName.substring(inputFileName.lastIndexOf(FILE_SEPARATOR)));
} else {
// if the 'master' file is not specified, just use the file name
return file.getName();
}
}