From 2946c6429e419e6312de8c72bab5ba762557cfcc Mon Sep 17 00:00:00 2001 From: mbirth Date: Mon, 17 Jan 2005 10:29:48 +0000 Subject: [PATCH] + Ignore initial CWD (there are stored the .jun-files, etc.) ! Path comparison is done with equalsIgnoreCase - so this will not work on UNIXish machines where the system differs between bla and blA+ Ignore initial CWD (b --- MyFilesystemParser.java | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/MyFilesystemParser.java b/MyFilesystemParser.java index 9cbbcc9..644e390 100644 --- a/MyFilesystemParser.java +++ b/MyFilesystemParser.java @@ -15,10 +15,13 @@ public class MyFilesystemParser { File logFile; private String curLine; + private String ignoreDir; private long counter; public MyFilesystemParser(String logfile) { logFile = new File(logfile+".gz"); + ignoreDir = System.getProperty("user.dir"); + while (ignoreDir.charAt(ignoreDir.length()-1)=='\\') ignoreDir = ignoreDir.substring(0, ignoreDir.length()-1); } public boolean driveIsWritable(char drive) { @@ -55,14 +58,21 @@ public class MyFilesystemParser { return result; } - /** Returns all files of a specified directory */ - public File[] listFiles(File dir) { + /** Returns all files of a specified directory + ATTENTION! ignoreDir has to contain a directory which should be ignored (temp, etc.). + The String must have no trailing backslash or slash. Also keep in mind that we work with + equalsIgnoreCase - so this won't work correctly on UNIXish machines + @param dir Directory to get contents of + @param noIgnoreDir If false, the startup-directory is ignored (because there are temporary files, data files, etc.) + @return File[] with File-Objects of all files in that directory + */ + public File[] listFiles(File dir, boolean noIgnoreDir) { String[] files = dir.list(); File[] result; - if (files != null) { + if ( files != null && ( !dir.getAbsolutePath().equalsIgnoreCase(ignoreDir) || noIgnoreDir )) { result = new File[files.length]; for (int i=0; i