changeset 152:f4a5cfe37469

Servlet version 1.16a1 - cleanup of DigilibConfig class - now uses new Parameter and ParameterMap classes - new parameter default-quality
author robcast
date Wed, 03 Sep 2003 00:54:38 +0200
parents bc8df0133c04
children 4980c969be4c
files servlet/src/digilib/io/DocuDirCache.java servlet/src/digilib/io/DocuDirectory.java servlet/src/digilib/io/FileOps.java
diffstat 3 files changed, 30 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/servlet/src/digilib/io/DocuDirCache.java	Mon Sep 01 18:21:27 2003 +0200
+++ b/servlet/src/digilib/io/DocuDirCache.java	Wed Sep 03 00:54:38 2003 +0200
@@ -111,7 +111,7 @@
 			// cache miss
 			misses++;
 			// see if it's a directory
-			File f = new File(baseDirNames[0] + fn);
+			File f = new File(baseDirNames[0], fn);
 			if (f.isDirectory()) {
 				dd = new DocuDirectory(fn, this);
 				if (dd.isValid()) {
@@ -175,7 +175,7 @@
 			// cache miss
 			misses++;
 			// see if it's a directory
-			File f = new File(baseDirNames[0] + fn);
+			File f = new File(baseDirNames[0], fn);
 			if (f.isDirectory()) {
 				dd = new DocuDirectory(fn, this);
 				if (dd.isValid()) {
--- a/servlet/src/digilib/io/DocuDirectory.java	Mon Sep 01 18:21:27 2003 +0200
+++ b/servlet/src/digilib/io/DocuDirectory.java	Wed Sep 03 00:54:38 2003 +0200
@@ -126,12 +126,12 @@
 		// array of base dirs
 		Directory[] dirs = new Directory[nb];
 		// the first directory has to exist
-		dir = new File(baseDirNames[0] + dirName);
+		dir = new File(baseDirNames[0],  dirName);
 
 		if (dir.isDirectory()) {
 			// fill array with the remaining directories
 			for (int j = 1; j < nb; j++) {
-				File d = new File(baseDirNames[j] + dirName);
+				File d = new File(baseDirNames[j],  dirName);
 				if (d.isDirectory()) {
 					dirs[j] = new Directory(d);
 				}
--- a/servlet/src/digilib/io/FileOps.java	Mon Sep 01 18:21:27 2003 +0200
+++ b/servlet/src/digilib/io/FileOps.java	Wed Sep 03 00:54:38 2003 +0200
@@ -78,6 +78,32 @@
 	}
 
 	/**
+	 * convert a string with a list of pathnames into an array of strings
+	 * using the system's path separator string
+	 */
+	public static String[] pathToArray(String paths) {
+		// split list into directories
+		StringTokenizer dirs =
+			new StringTokenizer(paths, File.pathSeparator);
+		int n = dirs.countTokens();
+		if (n < 1) {
+			return null;
+		}
+		// add directories into array
+		String[] pathArray = new String[n];
+		for (int i = 0; i < n; i++) {
+			String s = dirs.nextToken();
+			// make shure the dir name ends with a directory separator
+			if (s.endsWith(File.separator)) {
+				pathArray[i] = s;
+			} else {
+				pathArray[i] = s + File.separator;
+			}
+		}
+		return pathArray;
+	}
+
+	/**
 	 *  get a filehandle for a file or directory name
 	 *    returns File number n if fn is directory (starts with 1)
 	 */