diff options
author | mkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-05-13 09:13:31 +0000 |
---|---|---|
committer | mkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-05-13 09:13:31 +0000 |
commit | 8e2dc45759a8a549740954370f10c4973ee2aa52 (patch) | |
tree | 4f31beddee142afb687e3a3b376d800f72755434 /libjava/java/io/RandomAccessFile.java | |
parent | d957c480ac27a47b83b7d3e7b6e5105cdcd18573 (diff) | |
download | ppe42-gcc-8e2dc45759a8a549740954370f10c4973ee2aa52.tar.gz ppe42-gcc-8e2dc45759a8a549740954370f10c4973ee2aa52.zip |
2003-05-13 Michael Koch <konqueror@gmx.de>
* java/io/FileDescriptor.java
(SYNC): New constant.
(DSYNC): Likewise.
(getLength): Renamed from lenght() to match classpath's
FileDescriptor.java.
* java/io/RandomAccessFile.java
(RandomAccessFile): Removed unneeded mode check, implemented mode
"rws" and "rwd", merged documentation from classpath.
(setLength): Reformatted.
(length): Use new getLength() of FileDescriptor.
* java/io/natFileDescriptorEcos.cc
(getLength): Renamed from length().
* java/io/natFileDescriptorPosix.cc
(open): Implemented support for SYNC and DSYNC.
(seek): Use getLength() instead of length().
(getLength): Renamed from length().
* java/io/natFileDescriptorWin32.cc
(getLength): Renamed from length().
(seek): Use getLength() instead of length().
(available): Likewise.
* gnu/java/nio/natFileChannelImpl.cc
(size): Use getLength() instead of length().
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@66755 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/io/RandomAccessFile.java')
-rw-r--r-- | libjava/java/io/RandomAccessFile.java | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/libjava/java/io/RandomAccessFile.java b/libjava/java/io/RandomAccessFile.java index 990b2dcb5bd..0ff2ff65ce9 100644 --- a/libjava/java/io/RandomAccessFile.java +++ b/libjava/java/io/RandomAccessFile.java @@ -96,15 +96,17 @@ public class RandomAccessFile implements DataOutput, DataInput /** * This method initializes a new instance of <code>RandomAccessFile</code> * to read from the specified file name with the specified access mode. - * The access mode is either "r" for read only access or "rw" for read - * write access. + * The access mode is either "r" for read only access, "rw" for read + * write access, "rws" for synchronized read/write access of both + * content and metadata, or "rwd" for read/write access + * where only content is required to be synchronous. * <p> * Note that a <code>SecurityManager</code> check is made prior to * opening the file to determine whether or not this file is allowed to * be read or written. * * @param fileName The name of the file to read and/or write - * @param mode "r" for read only or "rw" for read-write access to the file + * @param mode "r", "rw", "rws", or "rwd" * * @exception IllegalArgumentException If <code>mode</code> has an * illegal value @@ -115,16 +117,21 @@ public class RandomAccessFile implements DataOutput, DataInput public RandomAccessFile (String fileName, String mode) throws FileNotFoundException { - // Check the mode - if (!mode.equals("r") && !mode.equals("rw") && !mode.equals("rws") && - !mode.equals("rwd")) - throw new IllegalArgumentException("Bad mode value: " + mode); - int fdmode; - if (mode.compareTo ("r") == 0) + if (mode.equals("r")) fdmode = FileDescriptor.READ; - else if (mode.compareTo ("rw") == 0) + else if (mode.equals("rw")) fdmode = FileDescriptor.READ | FileDescriptor.WRITE; + else if (mode.equals("rws")) + { + fdmode = (FileDescriptor.READ | FileDescriptor.WRITE + | FileDescriptor.SYNC); + } + else if (mode.equals("rwd")) + { + fdmode = (FileDescriptor.READ | FileDescriptor.WRITE + | FileDescriptor.DSYNC); + } else throw new IllegalArgumentException ("invalid mode: " + mode); @@ -197,9 +204,9 @@ public class RandomAccessFile implements DataOutput, DataInput * * @exception IOException If an error occurs */ - public void setLength (long pos) throws IOException + public void setLength (long newLen) throws IOException { - fd.setLength(pos); + fd.setLength (newLen); } /** @@ -211,7 +218,7 @@ public class RandomAccessFile implements DataOutput, DataInput */ public long length () throws IOException { - return fd.length(); + return fd.getLength (); } /** |