Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git

Get path to target file dynamically

AuthorDaveJarvis <email>
Date2023-07-11 15:59:13 GMT-0700
Commitc0e4e57559297bab72518a99abfd91d3998a1669
Parenta0ec1ee
Delta43 lines added, 41 lines removed, 2-line increase
src/test/java/com/keenwrite/processors/markdown/ImageLinkExtensionTest.java
.with( ProcessorContext.Mutator::setExportFormat, XHTML_TEX )
.with( ProcessorContext.Mutator::setCaret, () -> Caret.builder().build() )
- .with( ProcessorContext.Mutator::setImagesDir, imagesDir::toFile )
+ .with( ProcessorContext.Mutator::setImageDir, imagesDir::toFile )
.build();
}
src/main/java/com/keenwrite/typesetting/HostTypesetter.java
import static com.keenwrite.constants.Constants.DEFAULT_DIRECTORY;
+import static com.keenwrite.constants.Constants.TEMPORARY_DIRECTORY;
import static com.keenwrite.events.StatusEvent.clue;
import static java.lang.ProcessBuilder.Redirect.DISCARD;
-import static java.lang.System.getProperty;
import static java.nio.file.Files.*;
import static java.util.Arrays.asList;
@SuppressWarnings( "SpellCheckingInspection" )
private java.io.File getCacheDir() {
- final var temp = getProperty( "java.io.tmpdir" );
- final var cache = Path.of( temp, "luatex-cache" );
+ final var cache = Path.of( TEMPORARY_DIRECTORY, "luatex-cache" );
return cache.toFile();
}
src/main/java/com/keenwrite/typesetting/Typesetter.java
import java.util.concurrent.Callable;
+import static com.keenwrite.Bootstrap.USER_CACHE_DIR;
+import static com.keenwrite.constants.Constants.USER_DIRECTORY;
+import static com.keenwrite.constants.Constants.getFontDirectory;
import static com.keenwrite.events.StatusEvent.clue;
import static com.keenwrite.util.Time.toElapsedTime;
private Path mSourcePath;
private Path mTargetPath;
- private Path mThemesPath;
- private Path mImagesPath;
- private Path mCachesPath;
- private Path mFontsPath;
+ private Path mThemeDir = USER_DIRECTORY.toPath();
+ private Path mImageDir = USER_DIRECTORY.toPath();
+ private Path mCacheDir = USER_CACHE_DIR.toPath();
+ private Path mFontDir = getFontDirectory().toPath();
private boolean mAutoRemove;
/**
- * @param themePath Fully qualified path to the theme directory, which
- * ends with the selected theme name.
+ * @param themeDir Fully qualified path to the theme directory, which
+ * ends with the selected theme name.
*/
- public void setThemesPath( final Path themePath ) {
- mThemesPath = themePath;
+ public void setThemeDir( final Path themeDir ) {
+ mThemeDir = themeDir;
}
/**
- * @param imagePath Fully qualified path to the "images" directory.
+ * @param imageDir Fully qualified path to the "images" directory.
*/
- public void setImagesPath( final Path imagePath ) {
- mImagesPath = imagePath;
+ public void setImageDir( final Path imageDir ) {
+ mImageDir = imageDir;
}
/**
- * @param cachePath Fully qualified path to the "caches" directory.
+ * @param cacheDir Fully qualified path to the "caches" directory.
*/
- public void setCachesPath( final Path cachePath ) {
- mCachesPath = cachePath;
+ public void setCacheDir( final Path cacheDir ) {
+ mCacheDir = cacheDir;
}
/**
- * @param fontsPath Fully qualified path to the "fonts" directory.
+ * @param fontDir Fully qualified path to the "fonts" directory.
*/
- public void setFontsPath( final Path fontsPath ) {
- mFontsPath = fontsPath;
+ public void setFontDir( final Path fontDir ) {
+ mFontDir = fontDir;
}
}
- public Path getThemesPath() {
- return mThemesPath;
+ public Path getThemeDir() {
+ return mThemeDir;
}
- public Path getImagesPath() {
- return mImagesPath;
+ public Path getImageDir() {
+ return mImageDir;
}
- public Path getCachesPath() {
- return mCachesPath;
+ public Path getCacheDir() {
+ return mCacheDir;
}
- public Path getFontsPath() {
- return mFontsPath;
+ public Path getFontDir() {
+ return mFontDir;
}
final var sourcePath = getSourcePath().toString();
final var targetPath = getTargetPath().getFileName();
- final var themesPath = getThemesPath();
- final var imagesPath = getImagesPath();
- final var cachesPath = getCachesPath();
+ final var themesPath = getThemeDir();
+ final var imagesPath = getImageDir();
+ final var cachesPath = getCacheDir();
args.add(
format( "--arguments=themesdir=%s,imagesdir=%s,cachesdir=%s",
- themesPath, imagesPath, cachesPath )
+ themesPath, imagesPath, cachesPath )
);
args.add( format( "--path='%s'", themesPath ) );
}
- protected Path getThemesPath() {
- return mMutator.getThemesPath();
+ protected Path getThemeDir() {
+ return mMutator.getThemeDir();
}
- protected Path getImagesPath() {
- return mMutator.getImagesPath();
+ protected Path getImageDir() {
+ return mMutator.getImageDir();
}
- protected Path getCachesPath() {
- return mMutator.getCachesPath();
+ protected Path getCacheDir() {
+ return mMutator.getCacheDir();
}
- protected Path getFontsPath() {
- return mMutator.getFontsPath();
+ protected Path getFontDir() {
+ return mMutator.getFontDir();
}