Project

General

Profile

Feature #13568 ยป tmpfile-path.patch

sorah (Sorah Fukumori), 05/15/2017 10:35 AM

View differences:

io.c
5810 5810
rb_file_open_generic(VALUE io, VALUE filename, int oflags, int fmode,
5811 5811
                    const convconfig_t *convconfig, mode_t perm)
5812 5812
{
5813
    VALUE pathv;
5813 5814
    rb_io_t *fptr;
5814 5815
    convconfig_t cc;
5815 5816
    if (!convconfig) {
......
5825 5826
    MakeOpenFile(io, fptr);
5826 5827
    fptr->mode = fmode;
5827 5828
    fptr->encs = *convconfig;
5828
    fptr->pathv = rb_str_new_frozen(filename);
5829
    fptr->fd = rb_sysopen(fptr->pathv, oflags, perm);
5829
    pathv = rb_str_new_frozen(filename);
5830
#ifdef O_TMPFILE
5831
    if (!(oflags & O_TMPFILE))
5832
        fptr->pathv = pathv;
5833
#else
5834
    fptr->pathv = pathv;
5835
#endif
5836
    fptr->fd = rb_sysopen(pathv, oflags, perm);
5830 5837
    io_check_tty(fptr);
5831 5838
    if (fmode & FMODE_SETENC_BY_BOM) io_set_encoding_by_bom(io);
test/ruby/test_file.rb
468 468
      assert_file.not_exist?(path)
469 469
    end
470 470
  end
471

  
472
  def test_open_tempfile_path
473
    Dir.mktmpdir(__method__.to_s) do |tmpdir|
474
      File.open(tmpdir, File::RDWR | File::TMPFILE) do |io|
475
        io.write "foo"
476
        io.flush
477
        assert_nil io.path
478
        assert_equal 3, io.size
479
      end
480
    end
481
  end if File::Constants.const_defined?(:TMPFILE)
471 482
end
472
-