[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 8+3-filesystem support
From: |
Dr. Torsten Rupp |
Subject: |
Re: 8+3-filesystem support |
Date: |
Mon, 06 Sep 2004 09:52:17 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 |
Dear Mark,
Agreed. Could you supply a patch that cleans up the current code to
separate the 8.3 thing and the file separator thing to explicitly
mention something like fileSystem8_3 and introduces a system property
that the runtime should set when such a file system is set?
Attached to this email there is a patch. Please try it. It is still not
a nice implementation, because I still did not removed the
backslash-tests to keep it compatible with the current implementation in
Classpath. If everybody agree it would be a nice idea to separated the
pathname/filename handling functions into separated methods and clean-up
the code.
Best regards,
Torsten
--- File.java Mon Sep 6 09:42:54 2004
+++ File.java.new Mon Sep 6 09:44:55 2004
@@ -77,6 +77,16 @@
* <code>file.separator</code>system property.
*/
public static final char separatorChar = separator.charAt(0);
+
+ /* added properaty to check if filesystem is FAT (8+3-filenames)
+ This is needed on FAT-like filesystems where the filename
+ separator is "/" and not "\"
+ T. Rupp, 2004-09-01
+ */
+ /**
+ * true if filesystems is a 8+3-like filesystem with 8+3-naming
+ */
+ private static final boolean eightThreeFilesystem =
System.getProperty("file.8+3-filesystem","false").equals("true");
/**
* This is the string that is used to separate the host name from the
@@ -155,7 +165,11 @@
accept '/' as separator. In that case the following code
will fail.
*/
- String filename = (separatorChar!='\\')?"test-dir-write":"tst";
+ /* Check filesystem; if FAT also use 8+3-naming, even filename
+ separator char is not "\"
+ T. Rupp, 2004-09-01
+ */
+ String filename = ((separatorChar!='\\') ||
eightThreeFilesystem)?"test-dir-write":"tst";
File test = createTempFile(filename, null, this);
return (test != null && test.delete());
}
@@ -264,11 +278,15 @@
{
// On Windows, convert any '/' to '\'. This appears to be the same logic
// that Sun's Win32 Java performs.
- if (separatorChar == '\\')
+ /* Check filesystem; if FAT also use 8+3-naming, even filename
+ separator char is not "\"
+ T. Rupp, 2004-09-01
+ */
+ if ((separatorChar == '\\') || eightThreeFilesystem)
{
- p = p.replace ('/', '\\');
+ p = p.replace ('/', separatorChar);
// We have to special case the "\c:" prefix.
- if (p.length() > 2 && p.charAt(0) == '\\' &&
+ if (p.length() > 2 && p.charAt(0) == separatorChar &&
((p.charAt(1) >= 'a' && p.charAt(1) <= 'z') ||
(p.charAt(1) >= 'A' && p.charAt(1) <= 'Z')) &&
p.charAt(2) == ':')
@@ -288,7 +306,11 @@
// example, is a valid and minimal path).
if (plen > 1 && p.charAt (plen - 1) == separatorChar)
{
- if (! (separatorChar == '\\' && plen == 3 && p.charAt (1) == ':'))
+ /* Check filesystem; if FAT also use 8+3-naming, even filename
+ separator char is not "\"
+ T. Rupp, 2004-09-01
+ */
+ if (!(((separatorChar == '\\') || eightThreeFilesystem) && plen ==
3 && p.charAt (1) == ':'))
return p.substring (0, plen - 1);
}
else
@@ -317,7 +339,11 @@
int end;
if (plen > 1 && p.charAt (plen - 1) == separatorChar)
{
- if (separatorChar == '\\' && plen == 3 && p.charAt (1) == ':')
+ /* Check filesystem; if FAT also use 8+3-naming, even filename
+ separator char is not "\"
+ T. Rupp, 2004-09-01
+ */
+ if (((separatorChar == '\\') || eightThreeFilesystem) && plen == 3 &&
p.charAt (1) == ':')
end = plen;
else
end = plen - 1;
@@ -325,7 +351,7 @@
else
end = plen;
newpath.append(p.substring(last, end));
-
+
return newpath.toString();
}
@@ -424,15 +450,23 @@
{
if (isAbsolute())
return path;
- else if (separatorChar == '\\'
- && path.length() > 0 && path.charAt (0) == '\\')
+ /* Check filesystem; if FAT also use 8+3-naming, even filename
+ separator char is not "\"
+ T. Rupp, 2004-09-01
+ */
+ else if (((separatorChar == '\\') || eightThreeFilesystem)
+ && path.length() > 0 && path.charAt (0) == separatorChar)
{
// On Windows, even if the path starts with a '\\' it is not
// really absolute until we prefix the drive specifier from
// the current working directory to it.
return System.getProperty ("user.dir").substring (0, 2) + path;
}
- else if (separatorChar == '\\'
+ /* Check filesystem; if FAT also use 8+3-naming, even filename
+ separator char is not "\"
+ T. Rupp, 2004-09-01
+ */
+ else if (((separatorChar == '\\') || eightThreeFilesystem)
&& path.length() > 1 && path.charAt (1) == ':'
&& ((path.charAt (0) >= 'a' && path.charAt (0) <= 'z')
|| (path.charAt (0) >= 'A' && path.charAt (0) <= 'Z')))
@@ -448,14 +482,14 @@
}
catch (IOException e)
{
- drvDir = path.substring (0, 2) + "\\";
+ drvDir = path.substring (0, 2) + separatorChar;
}
// Note: this would return "C:\\." for the path "C:.", if "\"
// is the working folder on the C drive, but this is
// consistent with what Sun's JRE 1.4.1.01 actually returns!
if (path.length() > 2)
- return drvDir + '\\' + path.substring (2, path.length());
+ return drvDir + separatorChar + path.substring (2, path.length());
else
return drvDir;
}
@@ -493,13 +527,11 @@
{
// On Windows, getAbsolutePath might end up calling us, so we
// have to special case that call to avoid infinite recursion.
- if (separatorChar == '\\' && path.length() == 2 &&
+ if (((separatorChar == '\\') || eightThreeFilesystem) && path.length() ==
2 &&
((path.charAt(0) >= 'a' && path.charAt(0) <= 'z') ||
(path.charAt(0) >= 'A' && path.charAt(0) <= 'Z')) &&
path.charAt(1) == ':')
- {
return VMFile.toCanonicalForm(path);
- }
// Call getAbsolutePath first to make sure that we do the
// current directory handling, because the native code
// may have a different idea of the current directory.
@@ -549,14 +581,14 @@
// The "prefix", if present, is the leading "/" on UNIX and
// either the drive specifier (e.g. "C:") or the leading "\\"
// of a UNC network path on Windows.
- if (separatorChar == '/' && path.charAt (0) == '/')
+ if (((separatorChar == '/') && !eightThreeFilesystem) && path.charAt (0)
== separatorChar)
{
prefix = "/";
nameSeqIndex = 1;
}
- else if (separatorChar == '\\' && path.length() > 1)
+ else if (((separatorChar == '\\') || eightThreeFilesystem) &&
path.length() > 1)
{
- if ((path.charAt (0) == '\\' && path.charAt (1) == '\\')
+ if ((path.charAt (0) == separatorChar && path.charAt (1) ==
separatorChar)
|| (((path.charAt (0) >= 'a' && path.charAt (0) <= 'z')
|| (path.charAt (0) >= 'A' && path.charAt (0) <= 'Z'))
&& path.charAt (1) == ':'))
@@ -648,13 +680,13 @@
*/
public boolean isAbsolute()
{
- if (separatorChar == '\\')
+ if ((separatorChar == '\\') || eightThreeFilesystem)
return path.startsWith(dupSeparator) ||
(path.length() > 2 &&
((path.charAt(0) >= 'a' && path.charAt(0) <= 'z') ||
(path.charAt(0) >= 'A' && path.charAt(0) <= 'Z')) &&
path.charAt(1) == ':' &&
- path.charAt(2) == '\\');
+ path.charAt(2) == separatorChar);
else
return path.startsWith(separator);
}
@@ -960,7 +992,7 @@
if (isDirectory())
abspath = abspath + separatorChar;
- if (separatorChar == '\\')
+ if ((separatorChar == '\\') || eightThreeFilesystem)
abspath = separatorChar + abspath;
try
@@ -991,8 +1023,8 @@
{
// On Win32, Sun's JDK returns URLs of the form "file:/c:/foo/bar.txt",
// while on UNIX, it returns URLs of the form "file:/foo/bar.txt".
- if (separatorChar == '\\')
- return new URL ("file:/" + getAbsolutePath().replace ('\\', '/')
+ if ((separatorChar == '\\') || eightThreeFilesystem)
+ return new URL ("file:/" + getAbsolutePath().replace (separatorChar, '/')
+ (isDirectory() ? "/" : ""));
else
return new URL ("file:" + getAbsolutePath()
@@ -1109,7 +1141,7 @@
will fail.
*/
File file;
- if (separatorChar!='\\')
+ if ((separatorChar!='\\') || eightThreeFilesystem)
{
// probably a non-DOS-filesystem, use long names
do