diff options
author | Adrian Cumiskey <acumiskey@apache.org> | 2010-08-17 14:13:24 +0000 |
---|---|---|
committer | Adrian Cumiskey <acumiskey@apache.org> | 2010-08-17 14:13:24 +0000 |
commit | eef7367bea2aa614c052f8fc2b5ac90d5ae0df83 (patch) | |
tree | a420b79f4ab149d85eec0514cdbb55f03e127532 | |
parent | 7bf29deabefc04b28c2ad6019c6e3315e8dad95d (diff) | |
download | xmlgraphics-fop-eef7367bea2aa614c052f8fc2b5ac90d5ae0df83.tar.gz xmlgraphics-fop-eef7367bea2aa614c052f8fc2b5ac90d5ae0df83.zip |
-delete-cache command line argument replaced with -flush. Seems like a more common use case.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@986315 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/documentation/content/xdocs/trunk/running.xml | 3 | ||||
-rw-r--r-- | src/java/org/apache/fop/cli/CommandLineOptions.java | 43 | ||||
-rw-r--r-- | src/java/org/apache/fop/fonts/FontManager.java | 1 |
3 files changed, 20 insertions, 27 deletions
diff --git a/src/documentation/content/xdocs/trunk/running.xml b/src/documentation/content/xdocs/trunk/running.xml index 7e98a867c..11dc2848a 100644 --- a/src/documentation/content/xdocs/trunk/running.xml +++ b/src/documentation/content/xdocs/trunk/running.xml @@ -135,7 +135,8 @@ Fop [options] [-fo|-xml] infile [-xsl file] [-awt|-pdf|-mif|-rtf|-tiff|-png|-pcl -conserve enable memory-conservation policy (trades memory-consumption for disk I/O) (Note: currently only influences whether the area tree is serialized.) - -delete-cache deletes the current font cache file + -cache specifies a file/directory path location + -flush flushes the current font cache file [INPUT] infile xsl:fo input file (the same as the next) diff --git a/src/java/org/apache/fop/cli/CommandLineOptions.java b/src/java/org/apache/fop/cli/CommandLineOptions.java index 1d9b8c82b..fbd263633 100644 --- a/src/java/org/apache/fop/cli/CommandLineOptions.java +++ b/src/java/org/apache/fop/cli/CommandLineOptions.java @@ -130,6 +130,8 @@ public class CommandLineOptions { private String mimicRenderer = null; + private boolean flushCache = false; + /** * Construct a command line option object. */ @@ -167,7 +169,9 @@ public class CommandLineOptions { } checkSettings(); setUserConfig(); - + if (flushCache) { + flushCache(); + } //Factory config is set up, now we can create the user agent foUserAgent = factory.newFOUserAgent(); foUserAgent.getRendererOptions().putAll(renderingOptions); @@ -285,8 +289,8 @@ public class CommandLineOptions { factory.setStrictValidation(false); } else if (args[i].equals("-conserve")) { conserveMemoryPolicy = true; - } else if (args[i].equals("-delete-cache")) { - parseDeleteCacheOption(args, i); + } else if (args[i].equals("-flush")) { + flushCache = true; } else if (args[i].equals("-cache")) { parseCacheOption(args, i); } else if (args[i].equals("-dpi")) { @@ -401,26 +405,6 @@ public class CommandLineOptions { } } - private void parseDeleteCacheOption(String[] args, int i) throws FOPException { - FontManager fontManager = factory.getFontManager(); - try { - setUserConfig(); - File cacheFile = fontManager.getCacheFile(); - if (fontManager.deleteCache()) { - System.out.println("Successfully deleted the font cache file '" - + cacheFile + "'."); - System.exit(0); - } else { - System.err.println("Failed to delete the font cache file '" - + cacheFile + "'."); - System.exit(1); - } - } catch (IOException e) { - System.err.println("Failed to delete the font cache file"); - System.exit(1); - } - } - private int parseConfigurationOption(String[] args, int i) throws FOPException { if ((i + 1 == args.length) || (isOption(args[i + 1]))) { @@ -1205,9 +1189,9 @@ public class CommandLineOptions { + " (Note: currently only influences whether the area tree is" + " serialized.)\n\n" - + " -delete-cache delete the current font cache file and exit\n" + " -cache specifies a file/directory path location" - + " for the font cache file\n\n" + + " for the font cache file\n" + + " -flush flushes the current font cache file\n\n" + " [INPUT] \n" + " infile xsl:fo input file (the same as the next) \n" @@ -1381,5 +1365,14 @@ public class CommandLineOptions { } } + private void flushCache() throws FOPException { + FontManager fontManager = factory.getFontManager(); + File cacheFile = fontManager.getCacheFile(); + if (!fontManager.deleteCache()) { + System.err.println("Failed to flush the font cache file '" + + cacheFile + "'."); + System.exit(1); + } + } } diff --git a/src/java/org/apache/fop/fonts/FontManager.java b/src/java/org/apache/fop/fonts/FontManager.java index f989d2e3a..519dab6d5 100644 --- a/src/java/org/apache/fop/fonts/FontManager.java +++ b/src/java/org/apache/fop/fonts/FontManager.java @@ -202,7 +202,6 @@ public class FontManager { if (useCache) { if (cacheFile != null) { deleted = cacheFile.delete(); - cacheFile = null; } else { deleted = FontCache.getDefaultCacheFile(true).delete(); } |