diff servlet/src/digilib/io/FileOps.java @ 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 a398fc09ba71
children e743b853efca
line wrap: on
line diff
--- 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)
 	 */