[kaffe] CVS kaffe (guilhem): Classpath's IO/net subsystem merging + fixes.

Kaffe CVS cvs-commits at kaffe.org
Sat Aug 30 07:27:02 PDT 2003


PatchSet 3996 
Date: 2003/08/30 14:18:17
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
Classpath's IO/net subsystem merging + fixes.

See ChangeLog.

Members: 
	ChangeLog:1.1592->1.1593 
	configure:1.253->1.254 
	configure.in:1.220->1.221 
	config/config.h.in:1.77->1.78 
	include/Makefile.am:1.46->1.47 
	include/Makefile.in:1.118->1.119 
	include/jsyscall.h:1.12->1.13 
	kaffe/kaffevm/systems/unix-jthreads/syscalls.c:1.11->1.12 
	libraries/clib/io/File.c:1.19->1.20 
	libraries/clib/io/FileDescriptor.c:1.3->1.4 
	libraries/clib/io/FileInputStream.c:1.11->1.12(DEAD) 
	libraries/clib/io/FileOutputStream.c:1.10->1.11(DEAD) 
	libraries/clib/io/Makefile.am:1.8->1.9 
	libraries/clib/io/Makefile.in:1.72->1.73 
	libraries/clib/io/RandomAccessFile.c:1.10->1.11(DEAD) 
	libraries/clib/native/ClassLoader.c:1.35->1.36 
	libraries/clib/native/UNIXProcess.c:1.26->1.27 
	libraries/clib/net/InetAddressImpl.c:1.16->1.17 
	libraries/clib/net/Makefile.am:1.12->1.13 
	libraries/clib/net/Makefile.in:1.84->1.85 
	libraries/clib/net/NetworkInterface.c:1.1->1.2 
	libraries/clib/net/NetworkInterfaceImpl.c:1.2->1.3(DEAD) 
	libraries/clib/net/PlainDatagramSocketImpl.c:1.26->1.27 
	libraries/clib/net/PlainSocketImpl.c:1.30->1.31 
	libraries/javalib/Klasses.jar.bootstrap:1.33->1.34 
	libraries/javalib/Makefile.am:1.134->1.135 
	libraries/javalib/Makefile.in:1.181->1.182 
	libraries/javalib/bootstrap.classlist:1.26->1.27 
	libraries/javalib/essential.files:1.24->1.25 
	libraries/javalib/gnu/java/io/PlatformHelper.java:INITIAL->1.1 
	libraries/javalib/java/io/ByteArrayInputStream.java:1.4->1.5 
	libraries/javalib/java/io/ByteArrayOutputStream.java:1.10->1.11 
	libraries/javalib/java/io/Externalizable.java:1.3->1.4 
	libraries/javalib/java/io/File.java:1.34->1.35 
	libraries/javalib/java/io/FileDescriptor.java:1.4->1.5 
	libraries/javalib/java/io/FileInputStream.java:1.15->1.16 
	libraries/javalib/java/io/FileOutputStream.java:1.10->1.11 
	libraries/javalib/java/io/FileReader.java:1.3->1.4 
	libraries/javalib/java/io/FileWriter.java:1.4->1.5 
	libraries/javalib/java/io/InputStream.java:1.9->1.10 
	libraries/javalib/java/io/ObjectInputStream.java:1.25->1.26 
	libraries/javalib/java/io/OutputStream.java:1.1->1.2 
	libraries/javalib/java/io/PipedInputStream.java:1.12->1.13 
	libraries/javalib/java/io/PipedOutputStream.java:1.5->1.6 
	libraries/javalib/java/io/PipedReader.java:1.7->1.8 
	libraries/javalib/java/io/PipedWriter.java:1.3->1.4 
	libraries/javalib/java/io/RandomAccessFile.java:1.22->1.23 
	libraries/javalib/java/io/StringBufferInputStream.java:1.4->1.5 
	libraries/javalib/java/io/StringReader.java:1.7->1.8 
	libraries/javalib/java/io/StringWriter.java:1.6->1.7 
	libraries/javalib/java/net/DNSJavaInetAddressImpl.java:1.1->1.2(DEAD) 
	libraries/javalib/java/net/DatagramPacket.java:1.8->1.9 
	libraries/javalib/java/net/DatagramSocket.java:1.14->1.15 
	libraries/javalib/java/net/DatagramSocketImpl.java:1.4->1.5 
	libraries/javalib/java/net/DatagramSocketImplFactory.java:1.2->1.3 
	libraries/javalib/java/net/InetAddress.java:1.14->1.15 
	libraries/javalib/java/net/InetAddressImpl.java:1.6->1.7(DEAD) 
	libraries/javalib/java/net/MulticastSocket.java:1.9->1.10 
	libraries/javalib/java/net/NativeInetAddressImpl.java:1.1->1.2(DEAD) 
	libraries/javalib/java/net/NetworkInterface.java:1.2->1.3 
	libraries/javalib/java/net/NetworkInterfaceImpl.java:1.1->1.2(DEAD) 
	libraries/javalib/java/net/PlainDatagramSocketImpl.java:1.9->1.10 
	libraries/javalib/java/net/PlainSocketImpl.java:1.16->1.17 
	libraries/javalib/java/net/ServerSocket.java:1.15->1.16 
	libraries/javalib/java/net/Socket.java:1.25->1.26 
	libraries/javalib/java/net/SocketImpl.java:1.12->1.13 
	libraries/javalib/java/net/SocketImplFactory.java:1.3->1.4 
	libraries/javalib/java/net/SocketInputStream.java:1.7->1.8 
	libraries/javalib/java/net/SocketOptions.java:1.11->1.12 
	libraries/javalib/java/net/SocketOutputStream.java:1.3->1.4 
	libraries/javalib/java/net/SocketPermission.java:1.1->1.2 
	libraries/javalib/kaffe/net/DefaultDatagramSocketImplFactory.java:1.1->1.2(DEAD) 
	libraries/javalib/kaffe/net/DefaultSocketImplFactory.java:1.1->1.2(DEAD) 
	libraries/javalib/profiles/allatonce/all.files:1.19->1.20 
	libraries/javalib/profiles/default/core.files:1.14->1.15 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1592 kaffe/ChangeLog:1.1593
--- kaffe/ChangeLog:1.1592	Fri Aug 29 22:37:24 2003
+++ kaffe/ChangeLog	Sat Aug 30 14:18:17 2003
@@ -1,3 +1,125 @@
+2003-08-30  Guilhem Lavaux <guilhem at kaffe.org>
+
+	IO/net subsystem merging from Classpath. KJC's compile fix for next
+	check in.
+
+	* configure.in: Added detection of fsync and ftruncate.
+	
+	* include/Makefile.am: removed older kaffe's include files about
+	net subsystem. NOINSTALL_DERIVED_HDRS keep java_net_PlainSocketImpl.h,
+	java_net_PlainDatagramSocketImpl.h, java_net_InetAddress.h,
+	
+	* include/jsyscall.h:
+	(KFSYNC, _fsync) Added a new protected syscall to synchronize files.
+	
+	* kaffe/kaffevm/systems/unix-jthreads/syscalls.c:
+	(jthreadedFSync) added.
+
+	* libraries/clib/io/FileInputStream.c,
+	libraries/clib/io/FileOutputStream.c: removed.
+
+	* libraries/clib/io/File.c, libraries/clib/io/FileDescriptor.c,
+	libraries/clib/io/RandomAccessFile.c:
+	rewritten to match Classpath's native interface.
+
+	* libraries/clib/io/Makefile.am:
+	(libio_la_SOURCES) Removed FileInputStream.c, FileOutputStream.c,
+	RandomAccessFile.c
+
+	* libraries/clib/native/ClassLoader.c:
+	(java_lang_ClassLoader_defineClass0) check whether length==0 and
+	throws InvalidClassError (truncated class) in that case.
+
+	* libraries/clib/native/UNIXProcess.c:
+	(kaffe_lang_UNIXProcess_forkAndExec) Changed "fd" to "nativeFd" for
+	catched IO filedescriptors.
+	
+	* libraries/clib/net/Makefile.am:
+	(libnet_la_SOURCES) removed NetworkInterfaceImpl.c
+
+	* libraries/clib/net/InetAddressImpl.c: rewritten to match classpath's
+	native interface.
+
+	* libraries/clib/net/NetworkInterfaceImpl.c: removed.
+
+	* libraries/clib/net/NetworkInterface.c: rewritten.
+
+	* libraries/clib/net/PlainDatagramSocketImpl.c,
+	libraries/clib/net/PlainSocketImpl.c: adapted to classpath
+	structure. Kaffe's implementation is kept but external references have
+	changed.
+
+	* config/config.h.in, configure, include/Makefile.in,
+	libraries/clib/io/Makefile.in, libraries/clib/net/Makefile.in,
+	libraries/javalib/Klasses.jar.bootstrap,
+	libraries/javalib/Makefile.am, libraries/javalib/Makefile.in:
+	regenerated.
+
+	* libraries/javalib/bootstrap.classlist: Removed
+	java/net/NativeInetAddressImpl, java/net/InetAddressImpl.
+	Added gnu/java/io/PlatformHelper.
+	
+	* libraries/javalib/essential.files: Removed java/net/InetAddressImpl,
+	java/net/NativeInetAddressImpl.
+
+	* libraries/javalib/java/io/ByteArrayInputStream.java,
+	libraries/javalib/java/io/ByteArrayOutputStream.java,
+	libraries/javalib/java/io/Externalizable.java,
+	libraries/javalib/java/io/File.java,
+	libraries/javalib/java/io/FileDescriptor.java,
+	libraries/javalib/java/io/FileInputStream.java,
+	libraries/javalib/java/io/FileOutputStream.java,
+	libraries/javalib/java/io/FileReader.java,
+	libraries/javalib/java/io/FileWriter.java,
+	libraries/javalib/java/io/InputStream.java,
+	libraries/javalib/java/io/ObjectInputStream.java,
+	libraries/javalib/java/io/OutputStream.java,
+	libraries/javalib/java/io/PipedInputStream.java,
+	libraries/javalib/java/io/PipedOutputStream.java,
+	libraries/javalib/java/io/PipedReader.java,
+	libraries/javalib/java/io/PipedWriter.java,
+	libraries/javalib/java/io/RandomAccessFile.java,
+	libraries/javalib/java/io/StringBufferInputStream.java,
+	libraries/javalib/java/io/StringReader.java,
+	libraries/javalib/java/io/StringWriter.java,
+	libraries/javalib/java/net/DatagramPacket.java
+	libraries/javalib/java/net/DatagramSocketImpl.java
+	libraries/javalib/java/net/DatagramSocketImplFactory.java
+	libraries/javalib/java/net/InetAddress.java
+	libraries/javalib/java/net/MulticastSocket.java
+	libraries/javalib/java/net/DatagramSocket.java
+	libraries/javalib/java/net/NetworkInterface.java,
+	libraries/javalib/java/net/ServerSocket.java,
+	libraries/javalib/java/net/Socket.java,
+	libraries/javalib/java/net/SocketImpl.java,
+	libraries/javalib/java/net/SocketImplFactory.java,
+	libraries/javalib/java/net/SocketInputStream.java,
+	libraries/javalib/java/net/SocketOptions.java,
+	libraries/javalib/java/net/SocketOutputStream.java,
+	libraries/javalib/java/net/SocketPermission.java:
+	Imported from GNU Classpath + fixes to pass regression tests.
+	
+	* libraries/javalib/java/net/PlainSocketImpl.java:
+	(sendUrgentData) Added dummy method.
+	(connect) Added timeout conversion for kaffe.
+
+	* libraries/javalib/java/net/PlainDatagramSocketImpl.java:
+	(sendUrgentData) Added dummy method.
+	(setTimeToLive) changed the signature to match Java spec.
+	(PlainDatagramSocketImpl) Construct fd.
+	
+	
+	* libraries/javalib/java/net/DNSJavaInetAddressImpl.java,
+	libraries/javalib/java/net/InetAddressImpl.java,
+	libraries/javalib/java/net/NativeInetAddressImpl.java
+	libraries/javalib/java/net/NetworkInterfaceImpl.java: removed.
+
+	* libraries/javalib/profiles/default/core.files: Removed
+	java/net/NetworkInterfaceImpl, kaffe/net/DefaultSocketImplFactory,
+	kaffe/net/DefaultDatagramSocketImplFactory.
+
+	* libraries/javalib/profiles/default/allatonce/all.files: Regenerated.
+
 2003-08-29  Jim Pick  <jim at kaffe.org>
 
 	* libraries/javalib/java/io/RandomAccessFile.java:
@@ -63,6 +185,27 @@
 
 	* libraries/javalib/java/text/DecimalFormat.java:
 	Added import java.util.Currency to fix compile.
+
+2003-08-28  Guilhem Lavaux <guilhem at kaffe.org>
+
+	* libraries/javalib/java/util/Currency.java: new class.
+	
+	* libraries/javalib/java/text/DecimalFormatSymbols.java:
+	(locale) new field.
+	(readObject) check for version number and fix fields accordingly.
+	(getCurrency) new method.
+	(setCurrency) new method.
+
+	* libraries/javalib/java/text/NumberFormat.java:
+	(getCurrency) new method.
+	(setCurrency) new method. 
+
+	* libraries/javalib/java/text/DecimalFormat.java:
+	(getCurrency) new method.
+	(setCurrency) new method. 
+
+	* libraries/javalib/Makefile.am, libraries/javalib/Makefile.in:
+	regenerated.
 
 2003-08-28  Guilhem Lavaux <guilhem at kaffe.org>
 
Index: kaffe/configure
diff -u kaffe/configure:1.253 kaffe/configure:1.254
--- kaffe/configure:1.253	Thu Aug 28 02:53:35 2003
+++ kaffe/configure	Sat Aug 30 14:18:18 2003
@@ -40069,7 +40069,8 @@
 
 
 
-for ac_func in sync fsync
+
+for ac_func in sync fsync ftruncate
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 echo "$as_me:$LINENO: checking for $ac_func" >&5
Index: kaffe/configure.in
diff -u kaffe/configure.in:1.220 kaffe/configure.in:1.221
--- kaffe/configure.in:1.220	Thu Aug 28 02:53:37 2003
+++ kaffe/configure.in	Sat Aug 30 14:18:21 2003
@@ -1061,7 +1061,7 @@
 AC_CHECK_FUNCS([sbrk valloc memalign mallopt])
 AC_CHECK_FUNCS([mprotect madvise])
 AC_CHECK_FUNCS([waitpid kill fork execve execvp])
-AC_CHECK_FUNCS([sync fsync])
+AC_CHECK_FUNCS([sync fsync ftruncate])
 AC_CHECK_FUNCS([atexit on_exit vsnprintf snprintf])
 
 if test x"$Khost_cpu" = x"alpha" ; then
Index: kaffe/config/config.h.in
diff -u kaffe/config/config.h.in:1.77 kaffe/config/config.h.in:1.78
--- kaffe/config/config.h.in:1.77	Sat Jul 26 16:50:45 2003
+++ kaffe/config/config.h.in	Sat Aug 30 14:18:23 2003
@@ -100,6 +100,9 @@
 /* Define to 1 if you have the `ftime' function. */
 #undef HAVE_FTIME
 
+/* Define to 1 if you have the `ftruncate' function. */
+#undef HAVE_FTRUNCATE
+
 /* Enable GCJ support. */
 #undef HAVE_GCJ_SUPPORT
 
Index: kaffe/include/Makefile.am
diff -u kaffe/include/Makefile.am:1.46 kaffe/include/Makefile.am:1.47
--- kaffe/include/Makefile.am:1.46	Mon Aug 18 17:40:27 2003
+++ kaffe/include/Makefile.am	Sat Aug 30 14:18:23 2003
@@ -72,11 +72,8 @@
 	java_lang_reflect_Method.h \
 	java_net_DatagramPacket.h \
 	java_net_InetAddress.h \
-	java_net_InetAddressImpl.h \
-	java_net_NativeInetAddressImpl.h \
 	java_net_InetSocketAddress.h \
 	java_net_NetworkInterface.h \
-	java_net_NetworkInterfaceImpl.h \
 	java_net_PlainDatagramSocketImpl.h \
 	java_net_PlainSocketImpl.h \
 	java_net_SocketAddress.h \
Index: kaffe/include/Makefile.in
diff -u kaffe/include/Makefile.in:1.118 kaffe/include/Makefile.in:1.119
--- kaffe/include/Makefile.in:1.118	Mon Aug 18 17:40:27 2003
+++ kaffe/include/Makefile.in	Sat Aug 30 14:18:23 2003
@@ -307,11 +307,8 @@
 	java_lang_reflect_Method.h \
 	java_net_DatagramPacket.h \
 	java_net_InetAddress.h \
-	java_net_InetAddressImpl.h \
-	java_net_NativeInetAddressImpl.h \
 	java_net_InetSocketAddress.h \
 	java_net_NetworkInterface.h \
-	java_net_NetworkInterfaceImpl.h \
 	java_net_PlainDatagramSocketImpl.h \
 	java_net_PlainSocketImpl.h \
 	java_net_SocketAddress.h \
Index: kaffe/include/jsyscall.h
diff -u kaffe/include/jsyscall.h:1.12 kaffe/include/jsyscall.h:1.13
--- kaffe/include/jsyscall.h:1.12	Mon Aug  4 13:48:14 2003
+++ kaffe/include/jsyscall.h	Sat Aug 30 14:18:23 2003
@@ -35,6 +35,7 @@
 	int	(*_fstat)(int, struct stat*);
 	int	(*_stat)(const char*, struct stat*);
 	int	(*_ftruncate)(int, off_t);
+	int	(*_fsync)(int);
 
 	int	(*_mkdir)(const char*, int);
 	int	(*_rmdir)(const char*);
@@ -89,6 +90,7 @@
 #define	KFSTAT(A,B)	(*Kaffe_SystemCallInterface._fstat)(A,B)
 #define	KSTAT(A,B)	(*Kaffe_SystemCallInterface._stat)(A,B)
 #define KFTRUNCATE(A,B) (*Kaffe_SystemCallInterface._ftruncate)(A,B)
+#define KFSYNC(A)       (*Kaffe_SystemCallInterface._fsync)(A)
 
 #define	KMKDIR(A,B)	(*Kaffe_SystemCallInterface._mkdir)(A,B)
 #define	KRMDIR(A)	(*Kaffe_SystemCallInterface._rmdir)(A)
Index: kaffe/kaffe/kaffevm/systems/unix-jthreads/syscalls.c
diff -u kaffe/kaffe/kaffevm/systems/unix-jthreads/syscalls.c:1.11 kaffe/kaffe/kaffevm/systems/unix-jthreads/syscalls.c:1.12
--- kaffe/kaffe/kaffevm/systems/unix-jthreads/syscalls.c:1.11	Tue Aug  5 06:44:40 2003
+++ kaffe/kaffe/kaffevm/systems/unix-jthreads/syscalls.c	Sat Aug 30 14:18:24 2003
@@ -118,6 +118,7 @@
 static int
 jthreadedFTruncate(int fd, off_t new_size)
 {
+#ifdef HAVE_FTRUNCATE
 	int rc = 0;
 	jthread_spinon(0);
 	if (ftruncate(fd, new_size) == -1) {
@@ -125,6 +126,25 @@
 	}
 	jthread_spinoff(0);
 	return (rc);
+#else
+	return ENOTSUP;
+#endif
+}
+
+static int
+jthreadedFSync(int fd)
+{
+#ifdef HAVE_FSYNC
+	int rc = 0;
+	jthread_spinon(0);
+	if (fsync(fd) == -1) {
+		rc = errno;
+	}
+	jthread_spinoff(0);
+	return (rc);
+#else
+	return ENOTSUP;
+#endif
 }
 
 static int
@@ -385,6 +405,7 @@
         jthreadedFStat,
         jthreadedStat,
         jthreadedFTruncate,
+        jthreadedFSync,
         jthreadedMkdir,
         jthreadedRmdir,
         jthreadedRename,
Index: kaffe/libraries/clib/io/File.c
diff -u kaffe/libraries/clib/io/File.c:1.19 kaffe/libraries/clib/io/File.c:1.20
--- kaffe/libraries/clib/io/File.c:1.19	Wed Jun 11 22:26:17 2003
+++ kaffe/libraries/clib/io/File.c	Sat Aug 30 14:18:24 2003
@@ -3,6 +3,8 @@
  *
  * Copyright (c) 1996, 1997, 1998, 1999
  *	Transvirtual Technologies, Inc.  All rights reserved.
+ * Copyright (c) 2003
+ *      Kaffe's team.
  *
  * See the file "license.terms" for information on usage and redistribution 
  * of this file. 
@@ -30,89 +32,90 @@
 /*
  * Is named item a file?
  */
-jbool
-java_io_File_isFile0(struct Hjava_io_File* this)
+jboolean java_io_File_isFileInternal(struct Hjava_io_File* this, 
+				     struct Hjava_lang_String* fileName)
 {
-	struct stat buf;
-	char str[MAXPATHLEN];
-	int r;
-
-	stringJava2CBuf(unhand(this)->path, str, sizeof(str));
-
-	r = KSTAT(str, &buf);
-	if (r == 0 && S_ISREG(buf.st_mode)) {
-		return (1);
-	}
-	else {
-		return (0);
-	}
+  struct stat buf;
+  char str[MAXPATHLEN];
+  int r;
+  
+  stringJava2CBuf(fileName, str, sizeof(str));
+  
+  r = KSTAT(str, &buf);
+  if (r == 0 && S_ISREG(buf.st_mode)) {
+    return (1);
+  }
+  else {
+    return (0);
+  }
 }
 
 /*
  * Is named item a directory?
  */
-jbool
-java_io_File_isDirectory0(struct Hjava_io_File* this)
+jboolean java_io_File_isDirectoryInternal(struct Hjava_io_File* this,
+					  struct Hjava_lang_String* fileName)
 {
-	struct stat buf;
-	char str[MAXPATHLEN];
-	int r;
-
-	stringJava2CBuf(unhand(this)->path, str, sizeof(str));
-
-	r = KSTAT(str, &buf);
-	if (r == 0 && S_ISDIR(buf.st_mode)) {
-		return (1);
-	}
-	else {
-		return (0);
-	}
+  struct stat buf;
+  char str[MAXPATHLEN];
+  int r;
+
+  stringJava2CBuf(fileName, str, sizeof(str));
+  
+  r = KSTAT(str, &buf);
+  if (r == 0 && S_ISDIR(buf.st_mode)) {
+    return (1);
+  }
+  else {
+    return (0);
+  }
 }
 
 /*
  * Does named file exist?
  */
-jbool
-java_io_File_exists0(struct Hjava_io_File* this)
+jboolean java_io_File_existsInternal(struct Hjava_io_File* this,
+				     struct Hjava_lang_String* fileName)
 {
-	struct stat buf;
-	char str[MAXPATHLEN];
-
-	stringJava2CBuf(unhand(this)->path, str, sizeof(str));
-
-	/* A file exists if I can stat it */
-	return (KSTAT(str, &buf) == 0);
+  struct stat buf;
+  char str[MAXPATHLEN];
+  
+  stringJava2CBuf(fileName, str, sizeof(str));
+  
+  /* A file exists if I can stat it */
+  return (KSTAT(str, &buf) == 0);
 }
 
 /*
  * Last modified time on file.
  */
-jlong
-java_io_File_lastModified0(struct Hjava_io_File* this)
+jlong java_io_File_lastModifiedInternal(struct Hjava_io_File* this,
+					struct Hjava_lang_String* fileName)
 {
-	struct stat buf;
-	char str[MAXPATHLEN];
-	int r;
-
-	stringJava2CBuf(unhand(this)->path, str, sizeof(str));
-
-	r = KSTAT(str, &buf);
-	if (r != 0) {
-		return ((jlong)0);
-	}
-	return ((jlong)buf.st_mtime * (jlong)1000);
+  struct stat buf;
+  char str[MAXPATHLEN];
+  int r;
+  
+  stringJava2CBuf(fileName, str, sizeof(str));
+  
+  r = KSTAT(str, &buf);
+  if (r != 0) {
+    return ((jlong)0);
+  }
+  return ((jlong)buf.st_mtime * (jlong)1000);
 }
 
 /*
  * Can I write to this file?
  */
-jbool
-java_io_File_canWrite0(struct Hjava_io_File* this)
+jboolean
+java_io_File_canWriteInternal(struct Hjava_io_File* this,
+			      struct Hjava_lang_String* fileName)
 {
 	char str[MAXPATHLEN];
 	int r;
 
-	stringJava2CBuf(unhand(this)->path, str, sizeof(str));
+	stringJava2CBuf(fileName, str, sizeof(str));
 	/* XXX make part of jsyscall interface !? */
 	r = access(str, W_OK);
 	return (r < 0 ? 0 : 1);
@@ -121,261 +124,230 @@
 /*
  * Can I read from this file.
  */
-jbool
-java_io_File_canRead0(struct Hjava_io_File* this)
+jboolean java_io_File_canReadInternal(struct Hjava_io_File* this,
+				      struct Hjava_lang_String* fileName)
 {
-	char str[MAXPATHLEN];
-	int r;
-
-	stringJava2CBuf(unhand(this)->path, str, sizeof(str));
-	/* XXX make part of jsyscall interface !? */
-	r = access(str, R_OK);
-	return (r < 0 ? 0 : 1);
+  char str[MAXPATHLEN];
+  int r;
+  
+  stringJava2CBuf(fileName, str, sizeof(str));
+  /* XXX make part of jsyscall interface !? */
+  r = access(str, R_OK);
+  return (r < 0 ? 0 : 1);
 }
 
 /*
  * Return length of file.
  */
-jlong
-java_io_File_length0(struct Hjava_io_File* this)
+jlong java_io_File_lengthInternal(struct Hjava_io_File* this,
+				  struct Hjava_lang_String* fileName)
 {
-	struct stat buf;
-	char str[MAXPATHLEN];
-	int r;
-
-	stringJava2CBuf(unhand(this)->path, str, sizeof(str));
-
-	r = KSTAT(str, &buf);
-	if (r != 0) {
-		return ((jlong)0);
-	}
-	return ((jlong)buf.st_size);
+  struct stat buf;
+  char str[MAXPATHLEN];
+  int r;
+  
+  stringJava2CBuf(fileName, str, sizeof(str));
+  
+  r = KSTAT(str, &buf);
+  if (r != 0) {
+    return ((jlong)0);
+  }
+  return ((jlong)buf.st_size);
 }
 
 /*
  * Create a directory.
  */
-jbool
-java_io_File_mkdir0(struct Hjava_io_File* this)
+jboolean java_io_File_mkdirInternal(struct Hjava_io_File* this,
+				    struct Hjava_lang_String* fileName)
 {
-	char str[MAXPATHLEN];
-	int r;
-
-	stringJava2CBuf(unhand(this)->path, str, sizeof(str));
-	r = KMKDIR(str, 0777);
-	return (r != 0 ? 0 : 1);
+  char str[MAXPATHLEN];
+  int r;
+  
+  stringJava2CBuf(fileName, str, sizeof(str));
+  r = KMKDIR(str, 0777);
+  return (r != 0 ? 0 : 1);
 }
 
 /*
  * Rename a file.
  */
-jbool
-java_io_File_renameTo0(struct Hjava_io_File* this, struct Hjava_io_File* that)
-{
-	char str[MAXPATHLEN];
-	char str2[MAXPATHLEN];
-	int r;
-
-	stringJava2CBuf(unhand(this)->path, str, sizeof(str));
-	stringJava2CBuf(unhand(that)->path, str2, sizeof(str2));
-
-	r = KRENAME(str, str2);
-	return (r != 0 ? 0 : 1);
+jboolean java_io_File_renameToInternal(struct Hjava_io_File* this,
+				       struct Hjava_lang_String* fromName,
+				       struct Hjava_lang_String* toName)
+{
+  char str[MAXPATHLEN];
+  char str2[MAXPATHLEN];
+  int r;
+  
+  stringJava2CBuf(fromName, str, sizeof(str));
+  stringJava2CBuf(toName, str2, sizeof(str2));
+  
+  r = KRENAME(str, str2);
+  return (r != 0 ? 0 : 1);
 }
 
 /*
  * Delete a file.
  */
-jbool
-java_io_File_delete0(struct Hjava_io_File* this)
+jboolean java_io_File_deleteInternal(struct Hjava_io_File* this, 
+				    struct Hjava_lang_String* fileName)
 {
 	char str[MAXPATHLEN];
 	int r;
+	
+	stringJava2CBuf(fileName, str, sizeof(str));
 
-	stringJava2CBuf(unhand(this)->path, str, sizeof(str));
-	r = KREMOVE(str);
-	return(r != 0 ? 0 : 1);
-}
-
-/*
- * Delete a directory.
- */
-jbool
-java_io_File_rmdir0(struct Hjava_io_File* this)
-{
-	char str[MAXPATHLEN];
-	int r;
-
-	stringJava2CBuf(unhand(this)->path, str, sizeof(str));
-	r = KRMDIR(str);
+	if (java_io_File_isDirectoryInternal(this, fileName))
+	  r = KRMDIR(str);
+	else
+	  r = KREMOVE(str);
 	return(r != 0 ? 0 : 1);
 }
 
 /*
  * Get a directory listing.
  */
-HArrayOfObject* /* [Ljava.lang.String; */
-java_io_File_list0(struct Hjava_io_File* this)
+HArrayOfObject* java_io_File_listInternal(struct Hjava_io_File* this,
+					  struct Hjava_lang_String* dirName)
 {
 #if defined(HAVE_DIRENT_H)
-	char path[MAXPATHLEN];
-	DIR* dir;
-	struct dirent* entry;
-	struct dentry {
-		struct dentry* next;
-		char name[1];
-	};
-	struct dentry* dirlist;
-	struct dentry* mentry;
-	HArrayOfObject* array;
-	int count;
-	int i;
-	int oom = 0;
-
-	stringJava2CBuf(unhand(this)->path, path, sizeof(path));
-
-	/* XXX make part of jsyscall interface !? */
-	dir = opendir(path);
-	if (dir == 0) {
-		return (0);
-	}
-
-	dirlist = 0;
-	count = 0;
-	/* XXX make part of jsyscall interface !? */
-	while ((entry = readdir(dir)) != 0) {
-		/* We skip '.' and '..' */
-		if (strcmp(".", entry->d_name) == 0 ||
-		    strcmp("..", entry->d_name) == 0) {
-			continue;
-		}
-		mentry = KMALLOC(sizeof(struct dentry) + NAMLEN(entry));
-		if (!mentry) {
-			errorInfo info;
-
-			while (dirlist) {
-				mentry = dirlist;
-				dirlist = dirlist->next;
-				KFREE(mentry);
-			}
-			postOutOfMemory(&info);
-			throwError(&info);
-		}
-		strcpy(mentry->name, entry->d_name);
-		mentry->next = dirlist;
-		dirlist = mentry;
-		count++;
-	}
-	/* XXX make part of jsyscall interface !? */
-	closedir(dir);
-
-	array = (HArrayOfObject*)AllocObjectArray(count,
-	    "Ljava/lang/String;", 0);
-	/* XXX: This assert is a noop.  If AllocObjectArray throws an
-	   exception, we leak. */
-	assert(array != 0);
-	for (i = 0; i < count; i++) {
-		mentry = dirlist;
-		dirlist = mentry->next;
-		unhand_array(array)->body[i] =
-			(Hjava_lang_Object*)stringC2Java(mentry->name);
-		/* if allocation fails, continue freeing mentries in
-		   this loop. */
-		oom |= !unhand_array(array)->body[i];
-		KFREE(mentry);
-	}
-	if (oom) {
-		errorInfo info;
-		postOutOfMemory(&info);
-		throwError(&info);
-	}
-
-	return (array);
+  char path[MAXPATHLEN];
+  DIR* dir;
+  struct dirent* entry;
+  struct dentry {
+    struct dentry* next;
+    char name[1];
+  };
+  struct dentry* dirlist;
+  struct dentry* mentry;
+  HArrayOfObject* array;
+  int count;
+  int i;
+  int oom = 0;
+  
+  stringJava2CBuf(dirName, path, sizeof(path));
+  
+  /* XXX make part of jsyscall interface !? */
+  dir = opendir(path);
+  if (dir == 0) {
+    return (0);
+  }
+  
+  dirlist = 0;
+  count = 0;
+  /* XXX make part of jsyscall interface !? */
+  while ((entry = readdir(dir)) != 0) {
+    /* We skip '.' and '..' */
+    if (strcmp(".", entry->d_name) == 0 ||
+	strcmp("..", entry->d_name) == 0) {
+      continue;
+    }
+    mentry = KMALLOC(sizeof(struct dentry) + NAMLEN(entry));
+    if (!mentry) {
+      errorInfo info;
+      
+      while (dirlist) {
+	mentry = dirlist;
+	dirlist = dirlist->next;
+	KFREE(mentry);
+      }
+      postOutOfMemory(&info);
+      throwError(&info);
+    }
+    strcpy(mentry->name, entry->d_name);
+    mentry->next = dirlist;
+    dirlist = mentry;
+    count++;
+  }
+  /* XXX make part of jsyscall interface !? */
+  closedir(dir);
+  
+  array = (HArrayOfObject*)AllocObjectArray(count,
+					    "Ljava/lang/String;", 0);
+  /* XXX: This assert is a noop.  If AllocObjectArray throws an
+     exception, we leak. */
+  assert(array != 0);
+  for (i = 0; i < count; i++) {
+    mentry = dirlist;
+    dirlist = mentry->next;
+    unhand_array(array)->body[i] =
+      (Hjava_lang_Object*)stringC2Java(mentry->name);
+    /* if allocation fails, continue freeing mentries in
+       this loop. */
+    oom |= !unhand_array(array)->body[i];
+    KFREE(mentry);
+  }
+  if (oom) {
+    errorInfo info;
+    postOutOfMemory(&info);
+    throwError(&info);
+  }
+  
+  return (array);
 #else
-	return (0);
+  return (0);
 #endif
 }
 
-/*
- * Translate the given pathname into the local canonized form.
- * For the moment we just return what we're given.
- */
-struct Hjava_lang_String*
-java_io_File_canonPath(struct Hjava_io_File* this, struct Hjava_lang_String* str)
+jboolean java_io_File_createInternal(struct Hjava_lang_String* fileName)
 {
-	return (str);
-}
-
-/*
- * Is this filename absolute?
- */
-jbool
-java_io_File_isAbsolute(struct Hjava_io_File* this)
-{
-	char str[2];
-
-	stringJava2CBuf(unhand(this)->path, str, sizeof(str));
-	return (str[0] == file_separator[0]);
-}
-
-jboolean
-java_io_File_createNewFile0(struct Hjava_io_File* this, jint mode)
-{
-	char str[MAXPATHLEN];
-	int fd;
-	int rc;
-
-	stringJava2CBuf(unhand(this)->path, str, sizeof(str));
-
-	rc = KOPEN(str, O_EXCL|O_WRONLY|O_BINARY|O_CREAT, mode, &fd);
-	switch (rc) {
-	case 0:
-		break;
-	case EEXIST:
-		return 0;
-	default:
-		SignalError("java.io.IOException", SYS_ERROR(rc));
-	}
-	rc = KCLOSE(fd);
-	if (rc != 0)
-		SignalError("java.io.IOException", SYS_ERROR(rc));
-	return 1;
-}
-
-jboolean
-java_io_File_setLastModified0(struct Hjava_io_File* this, jlong thetime)
+  char str[MAXPATHLEN];
+  int fd;
+  int rc;
+  
+  stringJava2CBuf(fileName, str, sizeof(str));
+
+  rc = KOPEN(str, O_EXCL|O_WRONLY|O_BINARY|O_CREAT, 0600, &fd);
+  switch (rc) {
+  case 0:
+    break;
+  case EEXIST:
+    return 0;
+  default:
+    SignalError("java.io.IOException", SYS_ERROR(rc));
+  }
+  rc = KCLOSE(fd);
+  if (rc != 0)
+    SignalError("java.io.IOException", SYS_ERROR(rc));
+  return 1;
+}
+
+jboolean java_io_File_setLastModifiedInternal(struct Hjava_io_File* this,
+					      struct Hjava_lang_String* fileName,
+					      jlong thetime)
 {
 #ifdef HAVE_UTIME_H
-	char path[MAXPATHLEN];
-	struct utimbuf ub;
+  char path[MAXPATHLEN];
+  struct utimbuf ub;
 #endif
-
-	if (thetime < 0)
-		SignalError("java.lang.IllegalArgumentException", "time < 0");
+  
+  if (thetime < 0)
+    SignalError("java.lang.IllegalArgumentException", "time < 0");
 #ifdef HAVE_UTIME_H
-	stringJava2CBuf(unhand(this)->path, path, sizeof(path));
-	ub.actime = (time_t)(thetime / 1000);
-	ub.modtime = ub.actime;
-	return (utime(path, &ub) >= 0);
+  stringJava2CBuf(fileName, path, sizeof(path));
+  ub.actime = (time_t)(thetime / 1000);
+  ub.modtime = ub.actime;
+  return (utime(path, &ub) >= 0);
 #else
-	return 0;
+  return 0;
 #endif
 }
 
-jboolean
-java_io_File_setReadOnly0(struct Hjava_io_File* this)
+jboolean java_io_File_setReadOnlyInternal(struct Hjava_io_File* this, 
+					  struct Hjava_lang_String* fileName)
 {
-	struct stat buf;
-	char str[MAXPATHLEN];
-	int r;
-
-	stringJava2CBuf(unhand(this)->path, str, sizeof(str));
-
-	r = KSTAT(str, &buf);
-	if (r != 0)
-		return 0;
-
-	r = chmod(str, buf.st_mode & ~(S_IWOTH|S_IWGRP|S_IWUSR));
-	return (r == 0);
+  struct stat buf;
+  char str[MAXPATHLEN];
+  int r;
+  
+  stringJava2CBuf(fileName, str, sizeof(str));
+  
+  r = KSTAT(str, &buf);
+  if (r != 0)
+    return 0;
+  
+  r = chmod(str, buf.st_mode & ~(S_IWOTH|S_IWGRP|S_IWUSR));
+  return (r == 0);
 }
 
Index: kaffe/libraries/clib/io/FileDescriptor.c
diff -u kaffe/libraries/clib/io/FileDescriptor.c:1.3 kaffe/libraries/clib/io/FileDescriptor.c:1.4
--- kaffe/libraries/clib/io/FileDescriptor.c:1.3	Mon Feb  8 05:07:15 1999
+++ kaffe/libraries/clib/io/FileDescriptor.c	Sat Aug 30 14:18:24 2003
@@ -1,8 +1,7 @@
 /*
  * java.io.FileDescriptor.c
  *
- * Copyright (c) 1996, 1997
- *	Transvirtual Technologies, Inc.  All rights reserved.
+ * Copyright (c) 2003 Kaffe's team.
  *
  * See the file "license.terms" for information on usage and redistribution 
  * of this file. 
@@ -12,54 +11,439 @@
 #include "config-std.h"
 #include "config-io.h"
 #include "files.h"
+#include "defs.h"

*** Patch too long, truncated ***




More information about the kaffe mailing list