truncate(p1, p2)
  public
  
    
    
Truncates the file file_name to be at most integer bytes
long. Not available on all platforms.
f = File.new("out", "w")
f.write("1234567890")     
f.close                   
File.truncate("out", 5)   
File.size("out")          
   
  
    Show source    
    
      static VALUE
rb_file_s_truncate(VALUE klass, VALUE path, VALUE len)
{
    struct truncate_arg ta;
    int r;
    ta.pos = NUM2POS(len);
    FilePathValue(path);
    path = rb_str_encode_ospath(path);
    ta.path = StringValueCStr(path);
    r = (int)(VALUE)rb_thread_call_without_gvl(nogvl_truncate, &ta,
                                                RUBY_UBF_IO, NULL);
    if (r < 0)
        rb_sys_fail_path(path);
    return INT2FIX(0);
}