Skip to content
Permalink
Browse files
Fixes #2048
  • Loading branch information
enebo committed Dec 10, 2014
1 parent 2f56d95 commit 00e8c00bcdf0595148708ab975c46423e7895fbe
@@ -117,7 +117,7 @@ private void setup(String filename, boolean lstat) {
file = JRubyFile.createResource(runtime.getPosix(), runtime.getCurrentDirectory(), filename);
stat = lstat ? file.lstat() : file.stat();

if (stat == null) throw runtime.newErrnoFromInt(runtime.getPosix().errno(), filename);
if (stat == null) throw runtime.newErrnoFromInt(file.errno(), filename);
}

@JRubyMethod(name = "initialize", required = 1, visibility = Visibility.PRIVATE, compat = CompatVersion.RUBY1_8)
@@ -2,6 +2,7 @@

import java.io.IOException;
import java.io.InputStream;
import jnr.constants.platform.Errno;

abstract class AbstractFileResource implements FileResource {

@@ -10,6 +11,10 @@ public boolean canExecute() {
return false;
}

public int errno() {
return Errno.ENOENT.intValue();
}

@Override
public InputStream inputStream() throws ResourceException {
if (!exists()) {
@@ -1,5 +1,6 @@
package org.jruby.util;

import jnr.constants.platform.Errno;
import jnr.posix.FileStat;
import jnr.posix.POSIX;
import org.jruby.runtime.ThreadContext;
@@ -32,6 +33,10 @@ public boolean exists() {
return false;
}

public int errno() {
return Errno.ENOENT.intValue();
}

@Override
public boolean isDirectory() {
return false;
@@ -18,6 +18,7 @@ public interface FileResource {
boolean isDirectory();
boolean isFile();
boolean canExecute();
int errno();

long lastModified();
long length();
@@ -1,7 +1,6 @@
package org.jruby.util;

import jnr.posix.FileStat;
import jnr.posix.POSIX;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
@@ -72,6 +72,10 @@ public boolean canExecute() {
return file.canExecute();
}

public int errno() {
return posix.errno();
}

@Override
public boolean isFile() {
return file.isFile();

0 comments on commit 00e8c00

Please sign in to comment.