From: Jeremias Maerki Date: Wed, 11 Feb 2009 08:41:04 +0000 (+0000) Subject: Bugzilla #46686: X-Git-Tag: fop-1_0~317 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=34c5ece6364e11ba7dea02117b320e7e346abf09;p=xmlgraphics-fop.git Bugzilla #46686: Use temporary directory for the font cache if the user home directory is not write-accessible. Submitted by: Alok Singh Modifications to patch by jeremias: - Bugfix: original code switched to temporary directory if the .fop directory already existed in user home. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@743273 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/fonts/FontCache.java b/src/java/org/apache/fop/fonts/FontCache.java index fceeacb7b..9d5eff010 100644 --- a/src/java/org/apache/fop/fonts/FontCache.java +++ b/src/java/org/apache/fop/fonts/FontCache.java @@ -81,11 +81,18 @@ public final class FontCache implements Serializable { } private static File getUserHome() { - String s = System.getProperty("user.home"); - if (s != null) { - File userDir = new File(s); - if (userDir.exists()) { - return userDir; + return toDirectory(System.getProperty("user.home")); + } + + private static File getTempDirectory() { + return toDirectory(System.getProperty("java.io.tmpdir")); + } + + private static File toDirectory(String path) { + if (path != null) { + File dir = new File(path); + if (dir.exists()) { + return dir; } } return null; @@ -101,7 +108,15 @@ public final class FontCache implements Serializable { if (userHome != null) { File fopUserDir = new File(userHome, FOP_USER_DIR); if (forWriting) { - fopUserDir.mkdir(); + boolean writable = fopUserDir.canWrite(); + if (!fopUserDir.exists()) { + writable = fopUserDir.mkdir(); + } + if (!writable) { + userHome = getTempDirectory(); + fopUserDir = new File(userHome, FOP_USER_DIR); + fopUserDir.mkdir(); + } } return new File(fopUserDir, DEFAULT_CACHE_FILENAME); } diff --git a/status.xml b/status.xml index 2e6e4eb11..74393873d 100644 --- a/status.xml +++ b/status.xml @@ -58,6 +58,10 @@ documents. Example: the fix of marks layering will be such a case when it's done. --> + + Use temporary directory for the font cache if the user home directory is not + write-accessible. + AFP Fonts: Fixed interpretation of metric for fonts with fixed metrics and made sure all repeating groups in FNP (Font Position) are processed.