This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: File.getCanonicalPath on Windows?


>>>>> "Adam" == Adam Megacz <gcj@lists.megacz.com> writes:

Adam> I'll test it; post it here.

Appended.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	* java/io/natFileWin32.cc (getCanonicalPath): Treat "" like ".".
	For PR libgcj/6652.

Index: java/io/natFileWin32.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/natFileWin32.cc,v
retrieving revision 1.10
diff -u -r1.10 natFileWin32.cc
--- java/io/natFileWin32.cc 16 Apr 2002 15:37:39 -0000 1.10
+++ java/io/natFileWin32.cc 13 Jun 2002 14:31:58 -0000
@@ -99,13 +99,20 @@
 jstring
 java::io::File::getCanonicalPath (void)
 {
-  char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 1);
+  // We use `+2' here because we might need to use `.' for our special
+  // case.
+  char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 2);
   jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
+
+  // Special case: treat "" the same as ".".
+  if (total == 0)
+    buf[total++] = '.';
+
   buf[total] = '\0';
 
   LPTSTR unused;
   char buf2[MAX_PATH];
-  if(!GetFullPathName(buf, MAX_PATH, buf2, &unused))
+  if (! GetFullPathName(buf, MAX_PATH, buf2, &unused))
     throw new IOException (JvNewStringLatin1 ("GetFullPathName failed"));
 
   // FIXME: what encoding to assume for file names?  This affects many


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]