Skip to content

Instantly share code, notes, and snippets.

@bookshelfdave
Created January 3, 2012 18:58
Show Gist options
  • Save bookshelfdave/1556316 to your computer and use it in GitHub Desktop.
Save bookshelfdave/1556316 to your computer and use it in GitHub Desktop.
RubyIO tweak
public IRubyObject stat(ThreadContext context) {
openFile.checkClosed(context.getRuntime());
try {
if(this.popenSpecial == true) {
/*
This seems to work in OSX, but not Windows. I'm not sure how the impl of
file descriptors differs in Win32. Any ideas?
*/
int fd = (int)this.fileno(context).getLongValue();
// ends up calling POSIX.fstat(int)
return context.getRuntime().newFileStat(fd);
} else {
return context.getRuntime().newFileStat(getOpenFileChecked().getMainStreamSafe().getDescriptor().getFileDescriptor());
}
} catch (BadDescriptorException e) {
throw context.runtime.newErrnoEBADFError();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment