-
-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1212 from castwide/file_singleton_methods
Generate documentation for File singleton methods
- Loading branch information
Showing
3 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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); | ||
} |