Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: e136ac1ea40b
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 886ec64a917a
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Jan 10, 2017

  1. Copy the full SHA
    f170032 View commit details
  2. Copy the full SHA
    886ec64 View commit details
Showing with 7 additions and 14 deletions.
  1. +3 −3 core/src/main/java/org/jruby/ext/tempfile/Tempfile.java
  2. +4 −11 lib/ruby/stdlib/tempfile.rb
6 changes: 3 additions & 3 deletions core/src/main/java/org/jruby/ext/tempfile/Tempfile.java
Original file line number Diff line number Diff line change
@@ -110,9 +110,9 @@ private IRubyObject initializeCommon(ThreadContext context, IRubyObject[] args)
BlockCallback body = new TempfileCallback();

// #create and #make_tmpname come from Dir::Tmpname, included into
// tempfile in lib/ruby/shared/tempfile.rb. We use create here to
// tempfile in lib/ruby/stdlib/tempfile.rb. We use create here to
// match filename algorithm and allow them to be overridden.
callMethod(context, "create", args, CallBlock19.newCallClosure(this, this.getMetaClass(), Signature.OPTIONAL, body, context));
callMethod(context, "create", args, CallBlock19.newCallClosure(this, getMetaClass(), Signature.OPTIONAL, body, context));

// GH#1905: don't use JDK's deleteOnExit because it grows a set without bounds
context.runtime.addInternalFinalizer(Tempfile.this);
@@ -150,7 +150,7 @@ public IRubyObject call(ThreadContext context, IRubyObject[] args, Block block)
runtime.getPosix().chmod(tmp.getAbsolutePath(), 0600);
tmpFile = tmp;
} else {
throw context.runtime.newErrnoEEXISTError(openFile.getPath());
throw context.runtime.newErrnoEEXISTError(getPath());
}
} catch (IOException e) {
throw context.runtime.newIOErrorFromException(e);
15 changes: 4 additions & 11 deletions lib/ruby/stdlib/tempfile.rb
Original file line number Diff line number Diff line change
@@ -32,18 +32,11 @@ class Tempfile
# ... do something with f ...
# end
#
def Tempfile.create(basename, *rest)
def Tempfile.create(basename, tmpdir=nil, mode: 0, **options)
tmpfile = nil
Dir::Tmpname.create(basename, *rest) do |tmpname, n, opts|
mode = File::RDWR|File::CREAT|File::EXCL
perm = 0600
if opts
mode |= opts.delete(:mode) || 0
opts[:perm] = perm
perm = nil
else
opts = perm
end
Dir::Tmpname.create(basename, tmpdir, options) do |tmpname, n, opts|
mode |= File::RDWR|File::CREAT|File::EXCL
opts[:perm] = 0600
tmpfile = File.open(tmpname, mode, opts)
end
if block_given?