This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[PATCH] java.io.FileDescriptor
- From: Michael Koch <konqueror at gmx dot de>
- To: java-patches at gcc dot gnu dot org
- Date: Thu, 27 Feb 2003 11:21:55 +0100
- Subject: [PATCH] java.io.FileDescriptor
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi list,
This patch adds a truncate method to java.io.FileDescriptor. Its
currently "implemented" for Ecos and Posix. The windows people should
implement it for win32. The stub is there.
Please comment for review (this is for trunk only, I think).
Michael
- --
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE+XebDWSOgCCdjSDsRAqqoAJ96DI0CnnbCLA0h8M/WFAAXREehNACeNDfV
BnrOioVw2/j7NC6LpKiExM8=
=uhDF
-----END PGP SIGNATURE-----
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.1734
diff -u -r1.1734 ChangeLog
--- ChangeLog 25 Feb 2003 11:09:43 -0000 1.1734
+++ ChangeLog 27 Feb 2003 10:17:22 -0000
@@ -1,3 +1,14 @@
+2003-02-27 Michael Koch <konqueror at gmx dot de>
+
+ * java/io/FileDescriptor.java
+ (truncate): New method.
+ * java/io/natFileDescriptorEcos.cc
+ (truncate): New method.
+ * java/io/natFileDescriptorPosix.cc
+ (truncate): New method.
+ * java/io/natFileDescriptorWin32.cc
+ (truncate): New stubbed method.
+
2003-02-25 Michael Koch <konqueror at gmx dot de>
* gnu/java/nio/MappedByteFileBuffer.java,
Index: java/io/FileDescriptor.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/FileDescriptor.java,v
retrieving revision 1.11
diff -u -r1.11 FileDescriptor.java
--- java/io/FileDescriptor.java 4 Jan 2003 03:53:00 -0000 1.11
+++ java/io/FileDescriptor.java 27 Feb 2003 10:17:22 -0000
@@ -73,13 +73,14 @@
native int seek (long pos, int whence, boolean eof_trunc) throws IOException;
native long length () throws IOException;
native long getFilePointer () throws IOException;
+ native void truncate (long pos) throws IOException;
native int read () throws IOException;
native int read (byte[] bytes, int offset, int len) throws IOException;
native int available () throws IOException;
// When collected, close.
- protected void finalize () throws IOException
+ protected void finalize () throws Throwable
{
if (valid ())
close ();
Index: java/io/natFileDescriptorEcos.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/natFileDescriptorEcos.cc,v
retrieving revision 1.9
diff -u -r1.9 natFileDescriptorEcos.cc
--- java/io/natFileDescriptorEcos.cc 24 Jul 2002 17:48:41 -0000 1.9
+++ java/io/natFileDescriptorEcos.cc 27 Feb 2003 10:17:22 -0000
@@ -119,6 +119,11 @@
return 0;
}
+void
+java::io::FileDescriptor::truncate (jlong)
+{
+}
+
jint
java::io::FileDescriptor::read (void)
{
Index: java/io/natFileDescriptorPosix.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/natFileDescriptorPosix.cc,v
retrieving revision 1.24
diff -u -r1.24 natFileDescriptorPosix.cc
--- java/io/natFileDescriptorPosix.cc 4 Jan 2003 03:53:00 -0000 1.24
+++ java/io/natFileDescriptorPosix.cc 27 Feb 2003 10:17:22 -0000
@@ -272,6 +272,13 @@
return position;
}
+void
+java::io::FileDescriptor::truncate (jlong pos)
+{
+ if (::ftruncate (fd, pos) < 0)
+ throw new IOException (JvNewStringUTF (strerror (errno)));
+}
+
jint
java::io::FileDescriptor::read (void)
{
Index: java/io/natFileDescriptorWin32.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/natFileDescriptorWin32.cc,v
retrieving revision 1.12
diff -u -r1.12 natFileDescriptorWin32.cc
--- java/io/natFileDescriptorWin32.cc 11 Feb 2003 20:55:26 -0000 1.12
+++ java/io/natFileDescriptorWin32.cc 27 Feb 2003 10:17:22 -0000
@@ -282,6 +282,12 @@
return (((jlong)high) << 32L) | (jlong)low;
}
+void
+java::io::FileDescriptor::truncate (jlong pos)
+{
+ throw new IOException (JvNewStringLatin1 ("FileDescriptor::truncate: not implemented"));
+}
+
jint
java::io::FileDescriptor::read(void)
{