File: file.c.txt

package info (click to toggle)
yard 0.9.38-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,736 kB
  • sloc: ruby: 31,680; javascript: 7,658; makefile: 21
file content (28 lines) | stat: -rw-r--r-- 535 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
VALUE rb_cFile;

/*
 * call-seq:
 *    File.exist?(file_name)    ->  true or false
 *
 * Return <code>true</code> if the named file exists.
 *
 * _file_name_ can be an IO object.
 *
 * "file exists" means that stat() or fstat() system call is successful.
 */

static VALUE
rb_file_exist_p(VALUE obj, VALUE fname)
{
    struct stat st;

    if (rb_stat(fname, &st) < 0) return Qfalse;
    return Qtrue;
}

void
Init_File(void)
{
	rb_cFile = rb_define_class("File", rb_cIO);
    define_filetest_function("exist?", rb_file_exist_p, 1);
}