/** * Supprime tous les fichiers du repertoire. * * @param dir File directory to clean up * @param recursive true to go through all children of dir, false otherwise */ public static void cleanDirectoryAll(File dir, boolean recursive) { if (dir == null) { LOGGER.warning("Null directory"); return; } LOGGER.info("Clean directory " + dir.getAbsolutePath()); try { FileUtils.cleanDirectory(dir, new String[] {}, recursive); } catch (IOException e) { Engine.getLogger(AbstractSitoolsServerTestCase.class.getName()) .warning("Unable to clean " + dir.getPath() + "\n cause:" + e.getMessage()); } }
/** * Try to remove files from all the map directories under rootDir * * @param rootDir directory to be cleaned */ public static void cleanMapDirectories(File rootDir) { if (rootDir == null) { LOGGER.warning("Null directory"); return; } try { if (rootDir.getName().equals("map")) { FileUtils.cleanDirectory(rootDir, new String[] {"xml"}, false); } LOGGER.info("Clean XML files in maps directory " + rootDir.getAbsolutePath()); File[] children = rootDir.listFiles(); for (File file : children) { if (file.isDirectory()) { cleanMapDirectories(file); } } } catch (IOException e) { Engine.getLogger(AbstractSitoolsServerTestCase.class.getName()) .warning("Unable to clean " + rootDir.getPath() + "\n cause:" + e.getMessage()); } }