public String getPath() { if (openFile == null) return null; return openFile.getPath(); }
public String getPath() { if (openFile == null) return null; return openFile.getPath(); }
@Override public String toString() { return "RubyFile(" + openFile.getPath() + ", " + openFile.getMode() + ')'; }
@Override public String toString() { return "RubyFile(" + openFile.getPath() + ", " + openFile.getMode() + ')'; }
@JRubyMethod public IRubyObject path(ThreadContext context) { return context.runtime.newString(openFile.getPath()); }
@JRubyMethod public IRubyObject path(ThreadContext context) { return context.runtime.newString(openFile.getPath()); }
@JRubyMethod public IRubyObject addr(ThreadContext context) { Ruby runtime = context.runtime; return runtime.newArray( runtime.newString("AF_UNIX"), runtime.newString(openFile.getPath())); }
public void checkReopenSeek(ThreadContext context, Ruby runtime, long pos) { if (seek(context, pos, PosixShim.SEEK_SET) == -1 && errno() != null) { throw runtime.newErrnoFromErrno(errno(), getPath()); } }
public void checkReopenSeek(ThreadContext context, Ruby runtime, long pos) { if (seek(context, pos, PosixShim.SEEK_SET) == -1 && errno() != null) { throw runtime.newErrnoFromErrno(errno(), getPath()); } }
@JRubyMethod public IRubyObject addr(ThreadContext context) { Ruby runtime = context.runtime; return runtime.newArray( runtime.newString("AF_UNIX"), runtime.newString(openFile.getPath())); }
public static FileResource fileResource(ThreadContext context, IRubyObject pathOrFile) { Ruby runtime = context.runtime; if (pathOrFile instanceof RubyFile) { return JRubyFile.createResource(runtime, ((RubyFile) pathOrFile).getPath()); } else if (pathOrFile instanceof RubyIO) { return JRubyFile.createResource(runtime, ((RubyIO) pathOrFile).openFile.getPath()); } RubyString path = StringSupport.checkEmbeddedNulls(runtime, get_path(context, pathOrFile)); return JRubyFile.createResource(runtime, path.toString()); }
public static FileResource fileResource(ThreadContext context, IRubyObject pathOrFile) { Ruby runtime = context.runtime; if (pathOrFile instanceof RubyFile) { return JRubyFile.createResource(runtime, ((RubyFile) pathOrFile).getPath()); } else if (pathOrFile instanceof RubyIO) { return JRubyFile.createResource(runtime, ((RubyIO) pathOrFile).openFile.getPath()); } RubyString path = StringSupport.checkEmbeddedNulls(runtime, get_path(context, pathOrFile)); return JRubyFile.createResource(runtime, path.toString()); }
private long doSeek(ThreadContext context, long pos, int whence) { OpenFile fptr; fptr = getOpenFileChecked(); boolean locked = fptr.lock(); try { pos = fptr.seek(context, pos, whence); if (pos < 0 && fptr.errno() != null) { throw context.runtime.newErrnoFromErrno(fptr.errno(), fptr.getPath()); } } finally { if (locked) fptr.unlock(); } return 0; }
private long doSeek(ThreadContext context, long pos, int whence) { OpenFile fptr; fptr = getOpenFileChecked(); boolean locked = fptr.lock(); try { pos = fptr.seek(context, pos, whence); if (pos < 0 && fptr.errno() != null) { throw context.runtime.newErrnoFromErrno(fptr.errno(), fptr.getPath()); } } finally { if (locked) fptr.unlock(); } return 0; }
/** * Get the fully-qualified JRubyFile object for the path, taking into * account the runtime's current directory. */ public static FileResource fileResource(IRubyObject pathOrFile) { Ruby runtime = pathOrFile.getRuntime(); if (pathOrFile instanceof RubyIO) { return JRubyFile.createResource(runtime, ((RubyIO) pathOrFile).getOpenFileChecked().getPath()); } ThreadContext context = runtime.getCurrentContext(); RubyString path = StringSupport.checkEmbeddedNulls(runtime, get_path(context, pathOrFile)); return JRubyFile.createResource(runtime, path.toString()); }
/** * Get the fully-qualified JRubyFile object for the path, taking into * account the runtime's current directory. */ public static FileResource fileResource(IRubyObject pathOrFile) { Ruby runtime = pathOrFile.getRuntime(); if (pathOrFile instanceof RubyIO) { return JRubyFile.createResource(runtime, ((RubyIO) pathOrFile).getOpenFileChecked().getPath()); } ThreadContext context = runtime.getCurrentContext(); RubyString path = StringSupport.checkEmbeddedNulls(runtime, get_path(context, pathOrFile)); return JRubyFile.createResource(runtime, path.toString()); }
@JRubyMethod(name = {"pos", "tell"}) public RubyFixnum pos(ThreadContext context) { OpenFile fptr = getOpenFileChecked(); boolean locked = fptr.lock(); try { long pos = fptr.tell(context); if (pos == -1 && fptr.errno() != null) throw context.runtime.newErrnoFromErrno(fptr.errno(), fptr.getPath()); pos -= fptr.rbuf.len; return context.runtime.newFixnum(pos); } finally { if (locked) fptr.unlock(); } }
@JRubyMethod(name = {"pos", "tell"}) public RubyFixnum pos(ThreadContext context) { OpenFile fptr = getOpenFileChecked(); boolean locked = fptr.lock(); try { long pos = fptr.tell(context); if (pos == -1 && fptr.errno() != null) throw context.runtime.newErrnoFromErrno(fptr.errno(), fptr.getPath()); pos -= fptr.rbuf.len; return context.runtime.newFixnum(pos); } finally { if (locked) fptr.unlock(); } }
@JRubyMethod(name = "pos=", required = 1) public RubyFixnum pos_set(ThreadContext context, IRubyObject offset) { OpenFile fptr; long pos; pos = offset.convertToInteger().getLongValue(); fptr = getOpenFileChecked(); boolean locked = fptr.lock(); try { pos = fptr.seek(context, pos, PosixShim.SEEK_SET); if (pos == -1 && fptr.errno() != null) throw context.runtime.newErrnoFromErrno(fptr.errno(), fptr.getPath()); } finally { if (locked) fptr.unlock(); } return context.runtime.newFixnum(pos); }
@JRubyMethod(name = "pos=", required = 1) public RubyFixnum pos_set(ThreadContext context, IRubyObject offset) { OpenFile fptr; long pos; pos = offset.convertToInteger().getLongValue(); fptr = getOpenFileChecked(); boolean locked = fptr.lock(); try { pos = fptr.seek(context, pos, PosixShim.SEEK_SET); if (pos == -1 && fptr.errno() != null) throw context.runtime.newErrnoFromErrno(fptr.errno(), fptr.getPath()); } finally { if (locked) fptr.unlock(); } return context.runtime.newFixnum(pos); }