Permalink
Browse files

Main.java: Output files are named "basename_xmp.pdf". Output dir

works.
  • Loading branch information...
1 parent 9fd1899 commit f695b2a6d5f1b3021ec5d2be63b76d40dc8de45e @kjw kjw committed Dec 9, 2009
Showing with 20 additions and 2 deletions.
  1. +1 −0 .gitignore
  2. +19 −2 src/org/crossref/pdfmark/Main.java
View
@@ -2,3 +2,4 @@ bin
output
*.swp
*~
+pdfmark.jar
@@ -144,14 +144,22 @@ public Main(String[] args) {
* is already in each PDF. */
for (String pdfFilePath : parser.getRemainingArgs()) {
- String outputPath = pdfFilePath + ".out";
+ String outputPath = getOutFileName(pdfFilePath);
+
+ /* Grab the leaf. */
+ if (outputPath.contains(File.separator)) {
+ String[] split = outputPath.split(File.separator);
+ outputPath = split[split.length - 1];
+ }
if (!outputDir.isEmpty()) {
outputPath = outputDir + File.separator + outputPath;
+ } else {
+ /* Output to the working directory. */
}
File pdfFile = new File(pdfFilePath);
- File outputFile = new File(pdfFilePath + ".out");
+ File outputFile = new File(outputPath);
byte[] resolvedXmpData = null;
@@ -276,6 +284,15 @@ public void onFailure(String doi, int code, String msg) {
return builder.getXmpData();
}
+ private static String getOutFileName(String pdfFileName) {
+ if (pdfFileName.endsWith(".pdf")) {
+ return pdfFileName.substring(0, pdfFileName.length() - 4)
+ + "_xmp.pdf";
+ } else {
+ return pdfFileName + "_xmp.pdf";
+ }
+ }
+
private void exitWithError(int code, String error) {
shutDown();
System.err.println();

0 comments on commit f695b2a

Please sign in to comment.