diff options
author | Dalibor Topic <robilad@kaffe.org> | 2005-04-29 18:47:42 +0000 |
---|---|---|
committer | Michael Koch <mkoch@gcc.gnu.org> | 2005-04-29 18:47:42 +0000 |
commit | b61ae8b2611643a3f7005680573e4f13dcf9ef23 (patch) | |
tree | a633006bbff08f9d9c68b140ddd9e2656e06ec70 /libjava/gnu/java/nio/channels/FileChannelImpl.java | |
parent | 2c80f015490c820ec71549975d6276b41ed9ae4c (diff) | |
download | gcc-b61ae8b2611643a3f7005680573e4f13dcf9ef23.zip gcc-b61ae8b2611643a3f7005680573e4f13dcf9ef23.tar.gz gcc-b61ae8b2611643a3f7005680573e4f13dcf9ef23.tar.bz2 |
2005-04-29 Dalibor Topic <robilad@kaffe.org>
* java/nio/channels/FileChannelImpl.java
(FileChannelImpl(String, int)): Removed.
(FileChannelImpl(File, int)): Added. Check if opened file is a
directory.
* java/io/FileInputStream.java(FileInputStream): Fixed javadocs.
Call FileChannelImpl(File, int).
* java/io/FileOutputStream.java (FileInputStream): Call
FileChannelImpl(File, int).
* java/io/RandomAccessFile.java (RandomAccessFile):
Call FileChannelImpl(File, int). Switched constructors around.
From-SVN: r99011
Diffstat (limited to 'libjava/gnu/java/nio/channels/FileChannelImpl.java')
-rw-r--r-- | libjava/gnu/java/nio/channels/FileChannelImpl.java | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/libjava/gnu/java/nio/channels/FileChannelImpl.java b/libjava/gnu/java/nio/channels/FileChannelImpl.java index 9d978c9..aaa4c26 100644 --- a/libjava/gnu/java/nio/channels/FileChannelImpl.java +++ b/libjava/gnu/java/nio/channels/FileChannelImpl.java @@ -41,6 +41,7 @@ package gnu.java.nio.channels; import gnu.classpath.Configuration; import gnu.java.nio.FileLockImpl; +import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.nio.ByteBuffer; @@ -102,10 +103,27 @@ public final class FileChannelImpl extends FileChannel } /* Open a file. MODE is a combination of the above mode flags. */ - public FileChannelImpl (String path, int mode) throws FileNotFoundException + public FileChannelImpl (File file, int mode) throws FileNotFoundException { + final String path = file.getPath(); fd = open (path, mode); this.mode = mode; + + // First open the file and then check if it is a a directory + // to avoid race condition. + if (file.isDirectory()) + { + try + { + close(); + } + catch (IOException e) + { + /* ignore it */ + } + + throw new FileNotFoundException(path + " is a directory"); + } } /* Used by init() (native code) */ |