Commit 0fc920c8 by Michael Koch

[multiple changes]

2004-04-20  Jeroen Frijters  <jeroen@frijters.net>

	* java/io/FileDescriptor.java: (FileDescriptor) Added public
	constructor. (valid) Added null check.

2004-04-20  Guilhem Lavaux <guilhem@kaffe.org>

        Reported by Nektarios Papadopoulos <npapadop@inaccessnetworks.com>
	* java/io/FileOutputStream.java
	(FileOutputStream) Reorganized constructors. Constructors now
	check whether the given path is directory.

From-SVN: r80901
parent f6d49f66
2004-04-20 Jeroen Frijters <jeroen@frijters.net>
* java/io/FileDescriptor.java: (FileDescriptor) Added public
constructor. (valid) Added null check.
2004-04-20 Guilhem Lavaux <guilhem@kaffe.org>
Reported by Nektarios Papadopoulos <npapadop@inaccessnetworks.com>
* java/io/FileOutputStream.java
(FileOutputStream) Reorganized constructors. Constructors now
check whether the given path is directory.
2004-04-20 Michael Koch <konqueror@gmx.de> 2004-04-20 Michael Koch <konqueror@gmx.de>
* java/net/Authenticator.java, * java/net/Authenticator.java,
......
...@@ -83,6 +83,14 @@ public final class FileDescriptor ...@@ -83,6 +83,14 @@ public final class FileDescriptor
/** /**
* This method is used to initialize an invalid FileDescriptor object. * This method is used to initialize an invalid FileDescriptor object.
*/ */
public FileDescriptor()
{
channel = null;
}
/**
* This method is used to initialize a FileDescriptor object.
*/
FileDescriptor(ByteChannel channel) FileDescriptor(ByteChannel channel)
{ {
this.channel = channel; this.channel = channel;
...@@ -125,6 +133,6 @@ public final class FileDescriptor ...@@ -125,6 +133,6 @@ public final class FileDescriptor
*/ */
public boolean valid () public boolean valid ()
{ {
return channel.isOpen(); return channel != null && channel.isOpen();
} }
} }
...@@ -81,13 +81,7 @@ public class FileOutputStream extends OutputStream ...@@ -81,13 +81,7 @@ public class FileOutputStream extends OutputStream
public FileOutputStream (String path, boolean append) public FileOutputStream (String path, boolean append)
throws SecurityException, FileNotFoundException throws SecurityException, FileNotFoundException
{ {
SecurityManager s = System.getSecurityManager(); this (new File(path), append);
if (s != null)
s.checkWrite(path);
ch = new FileChannelImpl (path, (append
? FileChannelImpl.WRITE
| FileChannelImpl.APPEND
: FileChannelImpl.WRITE));
} }
/** /**
...@@ -130,7 +124,7 @@ public class FileOutputStream extends OutputStream ...@@ -130,7 +124,7 @@ public class FileOutputStream extends OutputStream
public FileOutputStream (File file) public FileOutputStream (File file)
throws SecurityException, FileNotFoundException throws SecurityException, FileNotFoundException
{ {
this (file.getPath(), false); this (file, false);
} }
/** /**
...@@ -156,7 +150,17 @@ public class FileOutputStream extends OutputStream ...@@ -156,7 +150,17 @@ public class FileOutputStream extends OutputStream
public FileOutputStream (File file, boolean append) public FileOutputStream (File file, boolean append)
throws FileNotFoundException throws FileNotFoundException
{ {
this (file.getPath(), append); SecurityManager s = System.getSecurityManager();
if (s != null)
s.checkWrite(file.getPath());
if (file.isDirectory())
throw new FileNotFoundException(file.getPath() + " is a directory");
ch = new FileChannelImpl (file.getPath(), (append
? FileChannelImpl.WRITE
| FileChannelImpl.APPEND
: FileChannelImpl.WRITE));
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment