--
Charles Oliver Nutter @ headius.blogspot.com
JRuby Developer @ www.jruby.org
Application Architect @ www.ventera.com
Index: src/org/jruby/RubyFile.java
===================================================================
RCS file: /cvsroot/jruby/jruby/src/org/jruby/RubyFile.java,v
retrieving revision 1.40
diff -u -r1.40 RubyFile.java
--- src/org/jruby/RubyFile.java 30 May 2006 17:52:48 -0000 1.40
+++ src/org/jruby/RubyFile.java 30 Jun 2006 00:56:16 -0000
@@ -44,6 +44,7 @@
import org.jruby.exceptions.RaiseException;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.IOHandler;
+import org.jruby.util.IOHandlerNull;
import org.jruby.util.IOHandlerSeekable;
import org.jruby.util.IOHandlerUnseekable;
import org.jruby.util.IOModes;
@@ -105,9 +106,13 @@
public void openInternal(String newPath, IOModes newModes) {
this.path = newPath;
this.modes = newModes;
-
+
try {
- handler = new IOHandlerSeekable(getRuntime(), newPath, newModes);
+ if (newPath.equals("/dev/null")) {
+ handler = new IOHandlerNull(getRuntime());
+ } else {
+ handler = new IOHandlerSeekable(getRuntime(), newPath, newModes);
+ }
registerIOHandler(handler);
} catch (InvalidValueException e) {
Index: src/org/jruby/util/IOHandlerNull.java
===================================================================
RCS file: src/org/jruby/util/IOHandlerNull.java
diff -N src/org/jruby/util/IOHandlerNull.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/jruby/util/IOHandlerNull.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,99 @@
+package org.jruby.util;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.nio.channels.FileChannel;
+
+import org.jruby.IRuby;
+
+public class IOHandlerNull extends IOHandler {
+
+ public IOHandlerNull(IRuby runtime) {
+ super(runtime);
+ }
+
+ public FileChannel getFileChannel() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String gets(String separatorString) throws IOException,
+ BadDescriptorException, EOFException {
+ throw new EOFException();
+ }
+
+ public String getsEntireStream() throws IOException,
+ BadDescriptorException, EOFException {
+ throw new EOFException();
+ }
+
+ public String read(int number) throws IOException, BadDescriptorException,
+ EOFException {
+ throw new EOFException();
+ }
+
+ public int write(String string) throws IOException, BadDescriptorException {
+ return string.length();
+ }
+
+ public int getc() throws IOException, BadDescriptorException, EOFException {
+ throw new EOFException();
+ }
+
+ public void ungetc(int c) {
+ }
+
+ public void putc(int c) throws IOException, BadDescriptorException {
+ }
+
+ public String sysread(int number) throws IOException,
+ BadDescriptorException, EOFException {
+ throw new EOFException();
+ }
+
+ public int syswrite(String buf) throws IOException, BadDescriptorException {
+ return buf.length();
+ }
+
+ public IOHandler cloneIOHandler() throws IOException, PipeException,
+ InvalidValueException {
+ return null;
+ }
+
+ public void close() throws IOException, BadDescriptorException {
+ }
+
+ public void flush() throws IOException, BadDescriptorException {
+ }
+
+ public void sync() throws IOException, BadDescriptorException {
+ }
+
+ public boolean isEOF() throws IOException, BadDescriptorException {
+ return true;
+ }
+
+ public int pid() {
+ return 0;
+ }
+
+ public long pos() throws IOException, PipeException {
+ return 0;
+ }
+
+ protected void resetByModes(IOModes newModes) throws IOException,
+ InvalidValueException {
+ }
+
+ public void rewind() throws IOException, PipeException,
+ InvalidValueException {
+ }
+
+ public void seek(long offset, int type) throws IOException, PipeException,
+ InvalidValueException {
+ }
+
+ public void truncate(long newLength) throws IOException, PipeException {
+ }
+
+}
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________ Jruby-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jruby-devel
