From dfcab91b89dbf7ffe375f9a0879c2af35f4a2d99 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 5 May 2014 13:01:06 -0400 Subject: [PATCH] hatch base dir keys() lookup repair Signed-off-by: Bill Erickson --- src/org/evergreen_ils/hatch/FileIO.java | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/org/evergreen_ils/hatch/FileIO.java b/src/org/evergreen_ils/hatch/FileIO.java index 861c05cd1e..0aa2fc785a 100644 --- a/src/org/evergreen_ils/hatch/FileIO.java +++ b/src/org/evergreen_ils/hatch/FileIO.java @@ -76,12 +76,9 @@ public class FileIO { } /** - * Locates the requested file by name within our configured base path. - * - * @param key The relative file name (key) - * @return The File object if found. + * Returns the base directory as a File for all file IO actions */ - protected File getFile(String key) { + protected File baseDir() { // basePath directory File dir = new File(basePath); @@ -100,10 +97,22 @@ public class FileIO { return null; } } - - logger.info("working with directory: " + subDir.getName()); + + logger.info("baseDir: " + subDir.getName()); + return subDir; + } + + /** + * Locates the requested file by name within our configured base path. + * + * @param key The relative file name (key) + * @return The File object if found. + */ + protected File getFile(String key) { + File baseDir = baseDir(); + if (baseDir == null) return null; key = cleanFileName(key); - return new File(subDir, key); + return new File(baseDir, key); } /** @@ -254,8 +263,9 @@ public class FileIO { public String[] keys(String prefix) { logger.info("keys => " + prefix); - File dir = new File(basePath); - if (!dir.exists()) return new String[0]; + File dir = baseDir(); + if (dir == null || !dir.exists()) + return new String[0]; LinkedList nameList = new LinkedList(); File[] files = dir.listFiles(); -- 2.11.0