Update of /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper2/util/io
In directory sc8-pr-cvs1:/tmp/cvs-serv25787/src/java/core/org/krysalis/ruper2/util/io
Modified Files:
FileUtils.java
Log Message:
Some doc tweaks...
Index: FileUtils.java
===================================================================
RCS file: /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper2/util/io/FileUtils.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** FileUtils.java 13 Oct 2003 13:24:42 -0000 1.3
--- FileUtils.java 14 Oct 2003 20:48:07 -0000 1.4
***************
*** 10,13 ****
--- 10,16 ----
import java.text.StringCharacterIterator;
+ import org.krysalis.ruper2.RuperRuntimeException;
+ import org.krysalis.ruper2.util.RuperConstants;
+
public class FileUtils {
***************
*** 58,82 ****
* @param file the file whose URL representation is required.
* @return The FileURL value
! * @throws MalformedURLException if the URL representation cannot be
! * formed.
*/
! public static URL getFileURL(File file) throws MalformedURLException {
! return new URL(toURI(file.getAbsolutePath()));
}
public static String toURI(String path) {
! boolean isDir = (new File(path)).isDirectory();
! StringBuffer sb = new StringBuffer("file:");
- sb.append("//");
// add an extra slash for filesystems with drive-specifiers
! if (!path.startsWith(File.separator)) {
sb.append("/");
}
! path = path.replace('\\', '/');
! CharacterIterator iter = new StringCharacterIterator(path);
for (char c = iter.first();
c != CharacterIterator.DONE;
--- 61,110 ----
* @param file the file whose URL representation is required.
* @return The FileURL value
! * @throws
*/
! public static URL getFileURL(File file) {
! URL url = null;
!
! String str = null;
! try
! {
! str = toURI(file.getAbsolutePath());
!
! url= new URL(str);
! }
! catch (MalformedURLException e) {
! //:TODO: Ought never happen, so it is a bug on
! // us ..
!
! throw new RuperRuntimeException("Bogus: " + str, e);
! }
!
! return url;
}
public static String toURI(String path) {
! return toURI(new File(path));
! }
!
! public static String toURI(File path){
! boolean isDir = path.isDirectory();
! String pathString = path.getAbsolutePath();
! StringBuffer sb = new StringBuffer(RuperConstants.FILE_PREFIX);
// add an extra slash for filesystems with drive-specifiers
! if (!pathString.startsWith(File.separator)) {
sb.append("/");
}
! //
! // Make and DOS \ into /
! //
! pathString = pathString.replace('\\', '/');
! //
! // Escaping..
! //
! CharacterIterator iter = new StringCharacterIterator(pathString);
for (char c = iter.first();
c != CharacterIterator.DONE;
***************
*** 91,97 ****
}
}
! if (isDir && !path.endsWith("/")) {
sb.append('/');
}
return sb.toString();
}
--- 119,130 ----
}
}
!
! //
! // Ensure directories end with a /
! //
! if (isDir && !pathString.endsWith("/")) {
sb.append('/');
}
+
return sb.toString();
}
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.