Project

General

Profile

Feature #11583 ยป file-unlink.patch

ksss (Yuki Kurihara), 10/12/2015 04:28 AM

View differences:

file.c
2867 2867
    return LONG2FIX(n);
2868 2868
}
2869 2869

  
2870
static VALUE
2871
rb_file_unlink(VALUE obj)
2872
{
2873
    rb_io_t *fptr;
2874
    const char *s;
2875

  
2876
    GetOpenFile(obj, fptr);
2877
    s = RSTRING_PTR(fptr->pathv);
2878
    unlink_internal(s, fptr->pathv, 0);
2879

  
2880
    return Qnil;
2881
}
2882

  
2870 2883
/*
2871 2884
 *  call-seq:
2872 2885
 *     File.rename(old_name, new_name)   -> 0
......
5999 6012
    rb_define_method(rb_cFile, "truncate", rb_file_truncate, 1);
6000 6013

  
6001 6014
    rb_define_method(rb_cFile, "flock", rb_file_flock, 1);
6015
    rb_define_method(rb_cFile, "unlink", rb_file_unlink, 0);
6002 6016

  
6003 6017
    /*
6004 6018
     * Document-module: File::Constants
test/ruby/test_file_exhaustive.rb
560 560
    assert_equal(1, File.unlink(regular_file))
561 561
    make_file("foo", regular_file)
562 562
    assert_raise(Errno::ENOENT) { File.unlink(nofile) }
563

  
564
    assert_equal(nil, File.open(regular_file){|f| f.unlink})
565
    assert_file.not_exist?(regular_file)
566
    make_file("foo", regular_file)
567

  
568
    assert_raise(Errno::ENOENT) { File.open(regular_file){|f| f.unlink; f.unlink} }
569
    assert_file.not_exist?(regular_file)
570
    make_file("foo", regular_file)
563 571
  end
564 572

  
565 573
  def test_rename