summaryrefslogtreecommitdiff
path: root/support/texplate/source/main/java/org/islandoftex/texplate/util/PathUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'support/texplate/source/main/java/org/islandoftex/texplate/util/PathUtils.java')
-rw-r--r--support/texplate/source/main/java/org/islandoftex/texplate/util/PathUtils.java36
1 files changed, 21 insertions, 15 deletions
diff --git a/support/texplate/source/main/java/org/islandoftex/texplate/util/PathUtils.java b/support/texplate/source/main/java/org/islandoftex/texplate/util/PathUtils.java
index 26e101b9ad..fa242c4980 100644
--- a/support/texplate/source/main/java/org/islandoftex/texplate/util/PathUtils.java
+++ b/support/texplate/source/main/java/org/islandoftex/texplate/util/PathUtils.java
@@ -2,11 +2,12 @@
package org.islandoftex.texplate.util;
import io.vavr.control.Try;
+import org.islandoftex.texplate.Main;
+
import java.io.FileNotFoundException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
-import org.islandoftex.texplate.Main;
/**
* Helper methods for path handling.
@@ -62,7 +63,6 @@ public class PathUtils {
*/
private static Path searchTemplatePath(String name)
throws FileNotFoundException {
-
// the file has to be a TOML format,
// so we add the extension
name = name.concat(".toml");
@@ -75,13 +75,11 @@ public class PathUtils {
// if the file actually exists,
// the search is done!
if (Files.exists(reference)) {
-
// return the template
// file reference
return reference;
} else {
-
// the reference was not found in the
// user location, so let us try the
// system counterpart
@@ -90,22 +88,30 @@ public class PathUtils {
// if the file actually exists,
// the search is done!
if (Files.exists(reference)) {
-
// return the template
// file reference
return reference;
} else {
-
- // the file reference could not be
- // found, so an exception is thrown
- throw new FileNotFoundException("I am sorry, but the template "
- + "file '" + name + "' could not be found in the "
- + "default template locations (system and user). Make "
- + "sure the reference is correct and try again. For "
- + "reference, these are the paths I searched: '"
- + getUserTemplatePath() + "' and '"
- + getDefaultTemplatePath() + "' (in this order).");
+ // in the system path, look for an `texplate` prefixed
+ // version as well
+ reference = getDefaultTemplatePath().resolve("texplate-" + name);
+
+ if (Files.exists(reference)) {
+ // return the template
+ // file reference
+ return reference;
+ } else {
+ // the file reference could not be
+ // found, so an exception is thrown
+ throw new FileNotFoundException("I am sorry, but the template "
+ + "file '" + name + "' could not be found in the "
+ + "default template locations (system and user). Make "
+ + "sure the reference is correct and try again. For "
+ + "reference, these are the paths I searched: '"
+ + getUserTemplatePath() + "' and '"
+ + getDefaultTemplatePath() + "' (in this order).");
+ }
}
}
}