You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ak...@hyperreal.org on 1999/11/08 04:59:53 UTC
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util FileUtil.java FilePathUtil.java
akv 99/11/07 19:59:52
Added: src/share/org/apache/tomcat/util FileUtil.java
Removed: src/share/org/apache/tomcat/util FilePathUtil.java
Log:
Rename + add one method.
Revision Changes Path
1.1 jakarta-tomcat/src/share/org/apache/tomcat/util/FileUtil.java
Index: FileUtil.java
===================================================================
/*
* $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/FileUtil.java,v 1.1 1999/11/08 03:59:52 akv Exp $
* $Revision: 1.1 $
* $Date: 1999/11/08 03:59:52 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.tomcat.util;
import java.io.File;
/*
* FileUtil contains utils for dealing with Files. Some of these are
* already present in JDK 1.2 but since we can rely on that and need
* to run on both JDK 1.1.x and JDK 1.2, we are replicating some of
* that code here.
*
* FileUtil also takes care of File.getAbsolutePath() and
* File.getNamePath() troubles when running on JDK 1.1.x/Windows
*
* @author James Todd [gonzo@eng.sun.com]
* @author Anil K. Vijendran [akv@eng.sun.com]
*/
public class FileUtil {
public static File[] listFiles(File dir) {
String[] ss = dir.list();
if (ss == null)
return null;
int n = ss.length;
File[] fs = new File[n];
for(int i = 0; i < n; i++) {
fs[i] = new File(dir.getPath(), ss[i]);
}
return fs;
}
public static String patch(String path) {
String patchPath = path.trim();
if (patchPath.length() >= 2 &&
Character.isLetter(patchPath.charAt(0)) &&
patchPath.charAt(1) == ':') {
char[] ca = patchPath.replace('/', '\\').toCharArray();
char c;
StringBuffer sb = new StringBuffer();
for (int i = 0; i < ca.length; i++) {
if ((ca[i] != '\\') ||
(ca[i] == '\\' &&
i > 0 &&
ca[i - 1] != '\\')) {
if (i == 0 &&
Character.isLetter(ca[i]) &&
i < ca.length - 1 &&
ca[i + 1] == ':') {
c = Character.toUpperCase(ca[i]);
} else {
c = ca[i];
}
sb.append(c);
}
}
patchPath = sb.toString();
}
return patchPath;
}
}