Permalink
Browse files

Commit made for @garybernhardt :love:

  • Loading branch information...
1 parent 9dc0d6f commit 7b611ea75acd30970d683bb56d6bea25ab92514c @iain committed Feb 21, 2012
Showing with 0 additions and 197 deletions.
  1. +0 −197 file.c
View
197 file.c
@@ -4203,203 +4203,6 @@ test_check(int n, int argc, VALUE *argv)
}
}
-#define CHECK(n) test_check((n), argc, argv)
-
-/*
- * call-seq:
- * test(int_cmd, file1 [, file2] ) -> obj
- *
- * Uses the integer +int_cmd+ to perform various tests on +file1+ (first
- * table below) or on +file1+ and +file2+ (second table).
- *
- * File tests on a single file:
- *
- * Test Returns Meaning
- * "A" | Time | Last access time for file1
- * "b" | boolean | True if file1 is a block device
- * "c" | boolean | True if file1 is a character device
- * "C" | Time | Last change time for file1
- * "d" | boolean | True if file1 exists and is a directory
- * "e" | boolean | True if file1 exists
- * "f" | boolean | True if file1 exists and is a regular file
- * "g" | boolean | True if file1 has the \CF{setgid} bit
- * | | set (false under NT)
- * "G" | boolean | True if file1 exists and has a group
- * | | ownership equal to the caller's group
- * "k" | boolean | True if file1 exists and has the sticky bit set
- * "l" | boolean | True if file1 exists and is a symbolic link
- * "M" | Time | Last modification time for file1
- * "o" | boolean | True if file1 exists and is owned by
- * | | the caller's effective uid
- * "O" | boolean | True if file1 exists and is owned by
- * | | the caller's real uid
- * "p" | boolean | True if file1 exists and is a fifo
- * "r" | boolean | True if file1 is readable by the effective
- * | | uid/gid of the caller
- * "R" | boolean | True if file is readable by the real
- * | | uid/gid of the caller
- * "s" | int/nil | If file1 has nonzero size, return the size,
- * | | otherwise return nil
- * "S" | boolean | True if file1 exists and is a socket
- * "u" | boolean | True if file1 has the setuid bit set
- * "w" | boolean | True if file1 exists and is writable by
- * | | the effective uid/gid
- * "W" | boolean | True if file1 exists and is writable by
- * | | the real uid/gid
- * "x" | boolean | True if file1 exists and is executable by
- * | | the effective uid/gid
- * "X" | boolean | True if file1 exists and is executable by
- * | | the real uid/gid
- * "z" | boolean | True if file1 exists and has a zero length
- *
- * Tests that take two files:
- *
- * "-" | boolean | True if file1 and file2 are identical
- * "=" | boolean | True if the modification times of file1
- * | | and file2 are equal
- * "<" | boolean | True if the modification time of file1
- * | | is prior to that of file2
- * ">" | boolean | True if the modification time of file1
- * | | is after that of file2
- */
-
-static VALUE
-rb_f_test(int argc, VALUE *argv)
-{
- int cmd;
-
- if (argc == 0) rb_raise(rb_eArgError, "wrong number of arguments (0 for 2..3)");
- cmd = NUM2CHR(argv[0]);
- if (cmd == 0) goto unknown;
- if (strchr("bcdefgGkloOprRsSuwWxXz", cmd)) {
- CHECK(1);
- switch (cmd) {
- case 'b':
- return rb_file_blockdev_p(0, argv[1]);
-
- case 'c':
- return rb_file_chardev_p(0, argv[1]);
-
- case 'd':
- return rb_file_directory_p(0, argv[1]);
-
- case 'a':
- case 'e':
- return rb_file_exist_p(0, argv[1]);
-
- case 'f':
- return rb_file_file_p(0, argv[1]);
-
- case 'g':
- return rb_file_sgid_p(0, argv[1]);
-
- case 'G':
- return rb_file_grpowned_p(0, argv[1]);
-
- case 'k':
- return rb_file_sticky_p(0, argv[1]);
-
- case 'l':
- return rb_file_symlink_p(0, argv[1]);
-
- case 'o':
- return rb_file_owned_p(0, argv[1]);
-
- case 'O':
- return rb_file_rowned_p(0, argv[1]);
-
- case 'p':
- return rb_file_pipe_p(0, argv[1]);
-
- case 'r':
- return rb_file_readable_p(0, argv[1]);
-
- case 'R':
- return rb_file_readable_real_p(0, argv[1]);
-
- case 's':
- return rb_file_size_p(0, argv[1]);
-
- case 'S':
- return rb_file_socket_p(0, argv[1]);
-
- case 'u':
- return rb_file_suid_p(0, argv[1]);
-
- case 'w':
- return rb_file_writable_p(0, argv[1]);
-
- case 'W':
- return rb_file_writable_real_p(0, argv[1]);
-
- case 'x':
- return rb_file_executable_p(0, argv[1]);
-
- case 'X':
- return rb_file_executable_real_p(0, argv[1]);
-
- case 'z':
- return rb_file_zero_p(0, argv[1]);
- }
- }
-
- if (strchr("MAC", cmd)) {
- struct stat st;
- VALUE fname = argv[1];
-
- CHECK(1);
- if (rb_stat(fname, &st) == -1) {
- FilePathValue(fname);
- rb_sys_fail(RSTRING_PTR(fname));
- }
-
- switch (cmd) {
- case 'A':
- return stat_atime(&st);
- case 'M':
- return stat_mtime(&st);
- case 'C':
- return stat_ctime(&st);
- }
- }
-
- if (cmd == '-') {
- CHECK(2);
- return rb_file_identical_p(0, argv[1], argv[2]);
- }
-
- if (strchr("=<>", cmd)) {
- struct stat st1, st2;
-
- CHECK(2);
- if (rb_stat(argv[1], &st1) < 0) return Qfalse;
- if (rb_stat(argv[2], &st2) < 0) return Qfalse;
-
- switch (cmd) {
- case '=':
- if (st1.st_mtime == st2.st_mtime) return Qtrue;
- return Qfalse;
-
- case '>':
- if (st1.st_mtime > st2.st_mtime) return Qtrue;
- return Qfalse;
-
- case '<':
- if (st1.st_mtime < st2.st_mtime) return Qtrue;
- return Qfalse;
- }
- }
- unknown:
- /* unknown command */
- if (ISPRINT(cmd)) {
- rb_raise(rb_eArgError, "unknown command '%s%c'", cmd == '\'' || cmd == '\\' ? "\\" : "", cmd);
- }
- else {
- rb_raise(rb_eArgError, "unknown command \"\\x%02X\"", cmd);
- }
- return Qnil; /* not reached */
-}
-
/*
* Document-class: File::Stat

2 comments on commit 7b611ea

@iain
Owner

I should check the emoji cheat sheet before committing....

Please sign in to comment.