Update of /cvsroot/jython/jython/org/python/core
In directory usw-pr-cvs1:/tmp/cvs-serv14117
Modified Files:
PyFile.java
Log Message:
Add truncate() method to files.
Index: PyFile.java
===================================================================
RCS file: /cvsroot/jython/jython/org/python/core/PyFile.java,v
retrieving revision 2.22
retrieving revision 2.23
diff -C2 -d -r2.22 -r2.23
*** PyFile.java 2001/10/28 17:13:43 2.22
--- PyFile.java 2001/11/28 19:19:54 2.23
***************
*** 54,57 ****
--- 54,60 ----
public void close() throws java.io.IOException {
}
+ public void truncate(long position) throws java.io.IOException {
+ throw new java.io.IOException("file doens't support truncate");
+ }
public Object __tojava__(Class cls) throws IOException {
***************
*** 472,475 ****
--- 475,483 ----
}
+ public void truncate(long position) throws java.io.IOException {
+ flush();
+ file.setLength(position);
+ }
+
public Object __tojava__(Class cls) throws IOException {
if (OutputStream.class.isAssignableFrom(cls) && writing)
***************
*** 565,568 ****
--- 573,580 ----
}
+ public void truncate(long position) throws java.io.IOException {
+ file.truncate(position);
+ }
+
public Object __tojava__(Class cls) throws IOException {
return file.__tojava__(cls);
***************
*** 868,871 ****
--- 880,900 ----
file = new FileWrapper();
}
+
+ public void truncate() {
+ try {
+ file.truncate(file.tell());
+ } catch (java.io.IOException e) {
+ throw Py.IOError(e);
+ }
+ }
+
+ public void truncate(long position) {
+ try {
+ file.truncate(position);
+ } catch (java.io.IOException e) {
+ throw Py.IOError(e);
+ }
+ }
+
// TBD: should this be removed? I think it's better to raise an
|