pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1867601 - /pdfbox/branches/issue45/fontbox/src/main/java/org/apache/fontbox/util/autodetect/FontFileFinder.java
Date Thu, 26 Sep 2019 18:18:02 GMT
Author: tilman
Date: Thu Sep 26 18:18:02 2019
New Revision: 1867601

URL: http://svn.apache.org/viewvc?rev=1867601&view=rev
Log:
PDFBOX-4071: simplify code

Modified:
    pdfbox/branches/issue45/fontbox/src/main/java/org/apache/fontbox/util/autodetect/FontFileFinder.java

Modified: pdfbox/branches/issue45/fontbox/src/main/java/org/apache/fontbox/util/autodetect/FontFileFinder.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue45/fontbox/src/main/java/org/apache/fontbox/util/autodetect/FontFileFinder.java?rev=1867601&r1=1867600&r2=1867601&view=diff
==============================================================================
--- pdfbox/branches/issue45/fontbox/src/main/java/org/apache/fontbox/util/autodetect/FontFileFinder.java
(original)
+++ pdfbox/branches/issue45/fontbox/src/main/java/org/apache/fontbox/util/autodetect/FontFileFinder.java
Thu Sep 26 18:18:02 2019
@@ -19,6 +19,7 @@ package org.apache.fontbox.util.autodete
 
 import java.io.File;
 import java.net.URI;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
 import org.apache.commons.logging.Log;
@@ -74,7 +75,7 @@ public class FontFileFinder
             fontDirFinder = determineDirFinder();
         }
         List<File> fontDirs = fontDirFinder.find();
-        List<URI> results = new java.util.ArrayList<URI>();
+        List<URI> results = new ArrayList<URI>();
         for (File dir : fontDirs)
         {
             walk(dir, results);
@@ -90,7 +91,7 @@ public class FontFileFinder
      */
     public List<URI> find(String dir)
     {
-        List<URI> results = new java.util.ArrayList<URI>();
+        List<URI> results = new ArrayList<URI>();
         File directory = new File(dir);
         if (directory.isDirectory())
         {
@@ -108,37 +109,39 @@ public class FontFileFinder
     private void walk(File directory, List<URI> results)
     {
         // search for font files recursively in the given directory
-        if (directory.isDirectory())
+        if (!directory.isDirectory())
+        {
+            return;
+        }
+        File[] filelist = directory.listFiles();
+        if (filelist == null)
         {
-            File[] filelist = directory.listFiles();
-            if (filelist != null)
+            return;
+        }
+        for (File file : filelist)
+        {
+            if (file.isDirectory())
             {
-                for (File file : filelist)
+                // skip hidden directories
+                if (file.getName().startsWith("."))
                 {
-                    if (file.isDirectory())
-                    {
-                        // skip hidden directories
-                        if (file.getName().startsWith("."))
-                        {
-                            continue;
-                        }
-                        walk(file, results);
-                    }
-                    else
+                    continue;
+                }
+                walk(file, results);
+            }
+            else
+            {
+                if (LOG.isDebugEnabled())
+                {
+                    LOG.debug("checkFontfile check " + file);
+                }
+                if (checkFontfile(file))
+                {
+                    if (LOG.isDebugEnabled())
                     {
-                        if (LOG.isDebugEnabled())
-                        {
-                            LOG.debug("checkFontfile check " + file);
-                        }
-                        if (checkFontfile(file))
-                        {
-                            if (LOG.isDebugEnabled())
-                            {
-                                LOG.debug("checkFontfile found " + file);
-                            }
-                            results.add(file.toURI());
-                        }
+                        LOG.debug("checkFontfile found " + file);
                     }
+                    results.add(file.toURI());
                 }
             }
         }



Mime
View raw message