Ruby  1.9.3p551(2014-11-13revision48407)
pathname.c
Go to the documentation of this file.
1 #include "ruby.h"
2 #include "ruby/encoding.h"
3 
6 
7 static VALUE
9 {
10  VALUE strpath;
11  strpath = rb_ivar_get(obj, id_at_path);
12  if (TYPE(strpath) != T_STRING)
13  rb_raise(rb_eTypeError, "unexpected @path");
14  return strpath;
15 }
16 
17 static void
19 {
20  rb_ivar_set(obj, id_at_path, val);
21 }
22 
23 /*
24  * Create a Pathname object from the given String (or String-like object).
25  * If +path+ contains a NUL character (<tt>\0</tt>), an ArgumentError is raised.
26  */
27 static VALUE
29 {
30  VALUE str;
31  if (TYPE(arg) == T_STRING) {
32  str = arg;
33  }
34  else {
35  str = rb_check_funcall(arg, id_to_path, 0, NULL);
36  if (str == Qundef)
37  str = arg;
38  StringValue(str);
39  }
40  if (memchr(RSTRING_PTR(str), '\0', RSTRING_LEN(str)))
41  rb_raise(rb_eArgError, "pathname contains null byte");
42  str = rb_obj_dup(str);
43 
44  set_strpath(self, str);
45  OBJ_INFECT(self, str);
46  return self;
47 }
48 
49 static VALUE
51 {
52  rb_call_super(0, 0);
54  return self;
55 }
56 
57 static VALUE
59 {
60  rb_call_super(0, 0);
62  return self;
63 }
64 
65 static VALUE
67 {
68  rb_call_super(0, 0);
70  return self;
71 }
72 
73 /*
74  * Compare this pathname with +other+. The comparison is string-based.
75  * Be aware that two different paths (<tt>foo.txt</tt> and <tt>./foo.txt</tt>)
76  * can refer to the same file.
77  */
78 static VALUE
79 path_eq(VALUE self, VALUE other)
80 {
81  if (!rb_obj_is_kind_of(other, rb_cPathname))
82  return Qfalse;
83  return rb_str_equal(get_strpath(self), get_strpath(other));
84 }
85 
86 /*
87  * Provides for comparing pathnames, case-sensitively.
88  */
89 static VALUE
90 path_cmp(VALUE self, VALUE other)
91 {
92  VALUE s1, s2;
93  char *p1, *p2;
94  char *e1, *e2;
95  if (!rb_obj_is_kind_of(other, rb_cPathname))
96  return Qnil;
97  s1 = get_strpath(self);
98  s2 = get_strpath(other);
99  p1 = RSTRING_PTR(s1);
100  p2 = RSTRING_PTR(s2);
101  e1 = p1 + RSTRING_LEN(s1);
102  e2 = p2 + RSTRING_LEN(s2);
103  while (p1 < e1 && p2 < e2) {
104  int c1, c2;
105  c1 = (unsigned char)*p1++;
106  c2 = (unsigned char)*p2++;
107  if (c1 == '/') c1 = '\0';
108  if (c2 == '/') c2 = '\0';
109  if (c1 != c2) {
110  if (c1 < c2)
111  return INT2FIX(-1);
112  else
113  return INT2FIX(1);
114  }
115  }
116  if (p1 < e1)
117  return INT2FIX(1);
118  if (p2 < e2)
119  return INT2FIX(-1);
120  return INT2FIX(0);
121 }
122 
123 /* :nodoc: */
124 static VALUE
126 {
127  return INT2FIX(rb_str_hash(get_strpath(self)));
128 }
129 
130 /*
131  * call-seq:
132  * pathname.to_s -> string
133  * pathname.to_path -> string
134  *
135  * Return the path as a String.
136  *
137  * to_path is implemented so Pathname objects are usable with File.open, etc.
138  */
139 static VALUE
141 {
142  return rb_obj_dup(get_strpath(self));
143 }
144 
145 /* :nodoc: */
146 static VALUE
148 {
149  const char *c = rb_obj_classname(self);
150  VALUE str = get_strpath(self);
151  return rb_sprintf("#<%s:%s>", c, RSTRING_PTR(str));
152 }
153 
154 /*
155  * Return a pathname which is substituted by String#sub.
156  */
157 static VALUE
159 {
160  VALUE str = get_strpath(self);
161 
162  if (rb_block_given_p()) {
163  str = rb_block_call(str, rb_intern("sub"), argc, argv, 0, 0);
164  }
165  else {
166  str = rb_funcall2(str, rb_intern("sub"), argc, argv);
167  }
168  return rb_class_new_instance(1, &str, rb_obj_class(self));
169 }
170 
171 /*
172  * Return a pathname which the extension of the basename is substituted by
173  * <i>repl</i>.
174  *
175  * If self has no extension part, <i>repl</i> is appended.
176  */
177 static VALUE
179 {
180  VALUE str = get_strpath(self);
181  VALUE str2;
182  long extlen;
183  const char *ext;
184  const char *p;
185 
186  StringValue(repl);
187  p = RSTRING_PTR(str);
188  extlen = RSTRING_LEN(str);
189  ext = ruby_enc_find_extname(p, &extlen, rb_enc_get(str));
190  if (ext == NULL) {
191  ext = p + RSTRING_LEN(str);
192  }
193  else if (extlen <= 1) {
194  ext += extlen;
195  }
196  str2 = rb_str_subseq(str, 0, ext-p);
197  rb_str_append(str2, repl);
198  OBJ_INFECT(str2, str);
199  return rb_class_new_instance(1, &str2, rb_obj_class(self));
200 }
201 
202 /* Facade for File */
203 
204 /*
205  * Returns the real (absolute) pathname of +self+ in the actual
206  * filesystem not containing symlinks or useless dots.
207  *
208  * All components of the pathname must exist when this method is
209  * called.
210  *
211  */
212 static VALUE
214 {
215  VALUE basedir, str;
216  rb_scan_args(argc, argv, "01", &basedir);
217  str = rb_funcall(rb_cFile, rb_intern("realpath"), 2, get_strpath(self), basedir);
218  return rb_class_new_instance(1, &str, rb_obj_class(self));
219 }
220 
221 /*
222  * Returns the real (absolute) pathname of +self+ in the actual filesystem.
223  * The real pathname doesn't contain symlinks or useless dots.
224  *
225  * The last component of the real pathname can be nonexistent.
226  */
227 static VALUE
229 {
230  VALUE basedir, str;
231  rb_scan_args(argc, argv, "01", &basedir);
232  str = rb_funcall(rb_cFile, rb_intern("realdirpath"), 2, get_strpath(self), basedir);
233  return rb_class_new_instance(1, &str, rb_obj_class(self));
234 }
235 
236 /*
237  * call-seq:
238  * pathname.each_line {|line| ... }
239  * pathname.each_line(sep=$/ [, open_args]) {|line| block } -> nil
240  * pathname.each_line(limit [, open_args]) {|line| block } -> nil
241  * pathname.each_line(sep, limit [, open_args]) {|line| block } -> nil
242  * pathname.each_line(...) -> an_enumerator
243  *
244  * #each_line iterates over the line in the file. It yields a String object
245  * for each line.
246  *
247  * This method is availabel since 1.8.1.
248  */
249 static VALUE
251 {
252  VALUE args[4];
253  int n;
254 
255  args[0] = get_strpath(self);
256  n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
257  if (rb_block_given_p()) {
258  return rb_block_call(rb_cIO, rb_intern("foreach"), 1+n, args, 0, 0);
259  }
260  else {
261  return rb_funcall2(rb_cIO, rb_intern("foreach"), 1+n, args);
262  }
263 }
264 
265 /*
266  * call-seq:
267  * pathname.read([length [, offset]]) -> string
268  * pathname.read([length [, offset]], open_args) -> string
269  *
270  * See <tt>IO.read</tt>. Returns all data from the file, or the first +N+ bytes
271  * if specified.
272  *
273  */
274 static VALUE
276 {
277  VALUE args[4];
278  int n;
279 
280  args[0] = get_strpath(self);
281  n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
282  return rb_funcall2(rb_cIO, rb_intern("read"), 1+n, args);
283 }
284 
285 /*
286  * call-seq:
287  * pathname.binread([length [, offset]]) -> string
288  *
289  * See <tt>IO.binread</tt>. Returns all the bytes from the file, or the first +N+
290  * if specified.
291  *
292  */
293 static VALUE
295 {
296  VALUE args[3];
297  int n;
298 
299  args[0] = get_strpath(self);
300  n = rb_scan_args(argc, argv, "02", &args[1], &args[2]);
301  return rb_funcall2(rb_cIO, rb_intern("binread"), 1+n, args);
302 }
303 
304 /*
305  * call-seq:
306  * pathname.readlines(sep=$/ [, open_args]) -> array
307  * pathname.readlines(limit [, open_args]) -> array
308  * pathname.readlines(sep, limit [, open_args]) -> array
309  *
310  * See <tt>IO.readlines</tt>. Returns all the lines from the file.
311  *
312  */
313 static VALUE
315 {
316  VALUE args[4];
317  int n;
318 
319  args[0] = get_strpath(self);
320  n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
321  return rb_funcall2(rb_cIO, rb_intern("readlines"), 1+n, args);
322 }
323 
324 /*
325  * call-seq:
326  * pathname.sysopen([mode, [perm]]) -> fixnum
327  *
328  * See <tt>IO.sysopen</tt>.
329  *
330  */
331 static VALUE
333 {
334  VALUE args[3];
335  int n;
336 
337  args[0] = get_strpath(self);
338  n = rb_scan_args(argc, argv, "02", &args[1], &args[2]);
339  return rb_funcall2(rb_cIO, rb_intern("sysopen"), 1+n, args);
340 }
341 
342 /*
343  * See <tt>File.atime</tt>. Returns last access time.
344  */
345 static VALUE
347 {
348  return rb_funcall(rb_cFile, rb_intern("atime"), 1, get_strpath(self));
349 }
350 
351 /*
352  * See <tt>File.ctime</tt>. Returns last (directory entry, not file) change time.
353  */
354 static VALUE
356 {
357  return rb_funcall(rb_cFile, rb_intern("ctime"), 1, get_strpath(self));
358 }
359 
360 /*
361  * See <tt>File.mtime</tt>. Returns last modification time.
362  */
363 static VALUE
365 {
366  return rb_funcall(rb_cFile, rb_intern("mtime"), 1, get_strpath(self));
367 }
368 
369 /*
370  * See <tt>File.chmod</tt>. Changes permissions.
371  */
372 static VALUE
374 {
375  return rb_funcall(rb_cFile, rb_intern("chmod"), 2, mode, get_strpath(self));
376 }
377 
378 /*
379  * See <tt>File.lchmod</tt>.
380  */
381 static VALUE
383 {
384  return rb_funcall(rb_cFile, rb_intern("lchmod"), 2, mode, get_strpath(self));
385 }
386 
387 /*
388  * See <tt>File.chown</tt>. Change owner and group of file.
389  */
390 static VALUE
391 path_chown(VALUE self, VALUE owner, VALUE group)
392 {
393  return rb_funcall(rb_cFile, rb_intern("chown"), 3, owner, group, get_strpath(self));
394 }
395 
396 /*
397  * See <tt>File.lchown</tt>.
398  */
399 static VALUE
400 path_lchown(VALUE self, VALUE owner, VALUE group)
401 {
402  return rb_funcall(rb_cFile, rb_intern("lchown"), 3, owner, group, get_strpath(self));
403 }
404 
405 /*
406  * call-seq:
407  * pathname.fnmatch(pattern, [flags]) -> string
408  * pathname.fnmatch?(pattern, [flags]) -> string
409  *
410  * See <tt>File.fnmatch</tt>. Return +true+ if the receiver matches the given
411  * pattern.
412  */
413 static VALUE
415 {
416  VALUE str = get_strpath(self);
417  VALUE pattern, flags;
418  if (rb_scan_args(argc, argv, "11", &pattern, &flags) == 1)
419  return rb_funcall(rb_cFile, rb_intern("fnmatch"), 2, pattern, str);
420  else
421  return rb_funcall(rb_cFile, rb_intern("fnmatch"), 3, pattern, str, flags);
422 }
423 
424 /*
425  * See <tt>File.ftype</tt>. Returns "type" of file ("file", "directory",
426  * etc).
427  */
428 static VALUE
430 {
431  return rb_funcall(rb_cFile, rb_intern("ftype"), 1, get_strpath(self));
432 }
433 
434 /*
435  * call-seq:
436  * pathname.make_link(old)
437  *
438  * See <tt>File.link</tt>. Creates a hard link at _pathname_.
439  */
440 static VALUE
442 {
443  return rb_funcall(rb_cFile, rb_intern("link"), 2, old, get_strpath(self));
444 }
445 
446 /*
447  * See <tt>File.open</tt>. Opens the file for reading or writing.
448  */
449 static VALUE
451 {
452  VALUE args[4];
453  int n;
454 
455  args[0] = get_strpath(self);
456  n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
457  if (rb_block_given_p()) {
458  return rb_block_call(rb_cFile, rb_intern("open"), 1+n, args, 0, 0);
459  }
460  else {
461  return rb_funcall2(rb_cFile, rb_intern("open"), 1+n, args);
462  }
463 }
464 
465 /*
466  * See <tt>File.readlink</tt>. Read symbolic link.
467  */
468 static VALUE
470 {
471  VALUE str;
472  str = rb_funcall(rb_cFile, rb_intern("readlink"), 1, get_strpath(self));
473  return rb_class_new_instance(1, &str, rb_obj_class(self));
474 }
475 
476 /*
477  * See <tt>File.rename</tt>. Rename the file.
478  */
479 static VALUE
481 {
482  return rb_funcall(rb_cFile, rb_intern("rename"), 2, get_strpath(self), to);
483 }
484 
485 /*
486  * See <tt>File.stat</tt>. Returns a <tt>File::Stat</tt> object.
487  */
488 static VALUE
490 {
491  return rb_funcall(rb_cFile, rb_intern("stat"), 1, get_strpath(self));
492 }
493 
494 /*
495  * See <tt>File.lstat</tt>.
496  */
497 static VALUE
499 {
500  return rb_funcall(rb_cFile, rb_intern("lstat"), 1, get_strpath(self));
501 }
502 
503 /*
504  * call-seq:
505  * pathname.make_symlink(old)
506  *
507  * See <tt>File.symlink</tt>. Creates a symbolic link.
508  */
509 static VALUE
511 {
512  return rb_funcall(rb_cFile, rb_intern("symlink"), 2, old, get_strpath(self));
513 }
514 
515 /*
516  * See <tt>File.truncate</tt>. Truncate the file to +length+ bytes.
517  */
518 static VALUE
520 {
521  return rb_funcall(rb_cFile, rb_intern("truncate"), 2, get_strpath(self), length);
522 }
523 
524 /*
525  * See <tt>File.utime</tt>. Update the access and modification times.
526  */
527 static VALUE
529 {
530  return rb_funcall(rb_cFile, rb_intern("utime"), 3, atime, mtime, get_strpath(self));
531 }
532 
533 /*
534  * See <tt>File.basename</tt>. Returns the last component of the path.
535  */
536 static VALUE
538 {
539  VALUE str = get_strpath(self);
540  VALUE fext;
541  if (rb_scan_args(argc, argv, "01", &fext) == 0)
542  str = rb_funcall(rb_cFile, rb_intern("basename"), 1, str);
543  else
544  str = rb_funcall(rb_cFile, rb_intern("basename"), 2, str, fext);
545  return rb_class_new_instance(1, &str, rb_obj_class(self));
546 }
547 
548 /*
549  * See <tt>File.dirname</tt>. Returns all but the last component of the path.
550  */
551 static VALUE
553 {
554  VALUE str = get_strpath(self);
555  str = rb_funcall(rb_cFile, rb_intern("dirname"), 1, str);
556  return rb_class_new_instance(1, &str, rb_obj_class(self));
557 }
558 
559 /*
560  * See <tt>File.extname</tt>. Returns the file's extension.
561  */
562 static VALUE
564 {
565  VALUE str = get_strpath(self);
566  return rb_funcall(rb_cFile, rb_intern("extname"), 1, str);
567 }
568 
569 /*
570  * See <tt>File.expand_path</tt>.
571  */
572 static VALUE
574 {
575  VALUE str = get_strpath(self);
576  VALUE dname;
577  if (rb_scan_args(argc, argv, "01", &dname) == 0)
578  str = rb_funcall(rb_cFile, rb_intern("expand_path"), 1, str);
579  else
580  str = rb_funcall(rb_cFile, rb_intern("expand_path"), 2, str, dname);
581  return rb_class_new_instance(1, &str, rb_obj_class(self));
582 }
583 
584 /*
585  * See <tt>File.split</tt>. Returns the #dirname and the #basename in an Array.
586  */
587 static VALUE
589 {
590  VALUE str = get_strpath(self);
591  VALUE ary, dirname, basename;
592  ary = rb_funcall(rb_cFile, rb_intern("split"), 1, str);
593  ary = rb_check_array_type(ary);
594  dirname = rb_ary_entry(ary, 0);
595  basename = rb_ary_entry(ary, 1);
596  dirname = rb_class_new_instance(1, &dirname, rb_obj_class(self));
597  basename = rb_class_new_instance(1, &basename, rb_obj_class(self));
598  return rb_ary_new3(2, dirname, basename);
599 }
600 
601 /*
602  * See <tt>FileTest.blockdev?</tt>.
603  */
604 static VALUE
606 {
607  return rb_funcall(rb_mFileTest, rb_intern("blockdev?"), 1, get_strpath(self));
608 }
609 
610 /*
611  * See <tt>FileTest.chardev?</tt>.
612  */
613 static VALUE
615 {
616  return rb_funcall(rb_mFileTest, rb_intern("chardev?"), 1, get_strpath(self));
617 }
618 
619 /*
620  * See <tt>FileTest.executable?</tt>.
621  */
622 static VALUE
624 {
625  return rb_funcall(rb_mFileTest, rb_intern("executable?"), 1, get_strpath(self));
626 }
627 
628 /*
629  * See <tt>FileTest.executable_real?</tt>.
630  */
631 static VALUE
633 {
634  return rb_funcall(rb_mFileTest, rb_intern("executable_real?"), 1, get_strpath(self));
635 }
636 
637 /*
638  * See <tt>FileTest.exist?</tt>.
639  */
640 static VALUE
642 {
643  return rb_funcall(rb_mFileTest, rb_intern("exist?"), 1, get_strpath(self));
644 }
645 
646 /*
647  * See <tt>FileTest.grpowned?</tt>.
648  */
649 static VALUE
651 {
652  return rb_funcall(rb_mFileTest, rb_intern("grpowned?"), 1, get_strpath(self));
653 }
654 
655 /*
656  * See <tt>FileTest.directory?</tt>.
657  */
658 static VALUE
660 {
661  return rb_funcall(rb_mFileTest, rb_intern("directory?"), 1, get_strpath(self));
662 }
663 
664 /*
665  * See <tt>FileTest.file?</tt>.
666  */
667 static VALUE
669 {
670  return rb_funcall(rb_mFileTest, rb_intern("file?"), 1, get_strpath(self));
671 }
672 
673 /*
674  * See <tt>FileTest.pipe?</tt>.
675  */
676 static VALUE
678 {
679  return rb_funcall(rb_mFileTest, rb_intern("pipe?"), 1, get_strpath(self));
680 }
681 
682 /*
683  * See <tt>FileTest.socket?</tt>.
684  */
685 static VALUE
687 {
688  return rb_funcall(rb_mFileTest, rb_intern("socket?"), 1, get_strpath(self));
689 }
690 
691 /*
692  * See <tt>FileTest.owned?</tt>.
693  */
694 static VALUE
696 {
697  return rb_funcall(rb_mFileTest, rb_intern("owned?"), 1, get_strpath(self));
698 }
699 
700 /*
701  * See <tt>FileTest.readable?</tt>.
702  */
703 static VALUE
705 {
706  return rb_funcall(rb_mFileTest, rb_intern("readable?"), 1, get_strpath(self));
707 }
708 
709 /*
710  * See <tt>FileTest.world_readable?</tt>.
711  */
712 static VALUE
714 {
715  return rb_funcall(rb_mFileTest, rb_intern("world_readable?"), 1, get_strpath(self));
716 }
717 
718 /*
719  * See <tt>FileTest.readable_real?</tt>.
720  */
721 static VALUE
723 {
724  return rb_funcall(rb_mFileTest, rb_intern("readable_real?"), 1, get_strpath(self));
725 }
726 
727 /*
728  * See <tt>FileTest.setuid?</tt>.
729  */
730 static VALUE
732 {
733  return rb_funcall(rb_mFileTest, rb_intern("setuid?"), 1, get_strpath(self));
734 }
735 
736 /*
737  * See <tt>FileTest.setgid?</tt>.
738  */
739 static VALUE
741 {
742  return rb_funcall(rb_mFileTest, rb_intern("setgid?"), 1, get_strpath(self));
743 }
744 
745 /*
746  * See <tt>FileTest.size</tt>.
747  */
748 static VALUE
750 {
751  return rb_funcall(rb_mFileTest, rb_intern("size"), 1, get_strpath(self));
752 }
753 
754 /*
755  * See <tt>FileTest.size?</tt>.
756  */
757 static VALUE
759 {
760  return rb_funcall(rb_mFileTest, rb_intern("size?"), 1, get_strpath(self));
761 }
762 
763 /*
764  * See <tt>FileTest.sticky?</tt>.
765  */
766 static VALUE
768 {
769  return rb_funcall(rb_mFileTest, rb_intern("sticky?"), 1, get_strpath(self));
770 }
771 
772 /*
773  * See <tt>FileTest.symlink?</tt>.
774  */
775 static VALUE
777 {
778  return rb_funcall(rb_mFileTest, rb_intern("symlink?"), 1, get_strpath(self));
779 }
780 
781 /*
782  * See <tt>FileTest.writable?</tt>.
783  */
784 static VALUE
786 {
787  return rb_funcall(rb_mFileTest, rb_intern("writable?"), 1, get_strpath(self));
788 }
789 
790 /*
791  * See <tt>FileTest.world_writable?</tt>.
792  */
793 static VALUE
795 {
796  return rb_funcall(rb_mFileTest, rb_intern("world_writable?"), 1, get_strpath(self));
797 }
798 
799 /*
800  * See <tt>FileTest.writable_real?</tt>.
801  */
802 static VALUE
804 {
805  return rb_funcall(rb_mFileTest, rb_intern("writable_real?"), 1, get_strpath(self));
806 }
807 
808 /*
809  * See <tt>FileTest.zero?</tt>.
810  */
811 static VALUE
813 {
814  return rb_funcall(rb_mFileTest, rb_intern("zero?"), 1, get_strpath(self));
815 }
816 
817 static VALUE
819 {
820  return rb_yield(rb_class_new_instance(1, &elt, klass));
821 }
822 
823 /*
824  * See <tt>Dir.glob</tt>. Returns or yields Pathname objects.
825  */
826 static VALUE
828 {
829  VALUE args[2];
830  int n;
831 
832  n = rb_scan_args(argc, argv, "11", &args[0], &args[1]);
833  if (rb_block_given_p()) {
834  return rb_block_call(rb_cDir, rb_intern("glob"), n, args, glob_i, klass);
835  }
836  else {
837  VALUE ary;
838  long i;
839  ary = rb_funcall2(rb_cDir, rb_intern("glob"), n, args);
840  ary = rb_convert_type(ary, T_ARRAY, "Array", "to_ary");
841  for (i = 0; i < RARRAY_LEN(ary); i++) {
842  VALUE elt = RARRAY_PTR(ary)[i];
843  elt = rb_class_new_instance(1, &elt, klass);
844  rb_ary_store(ary, i, elt);
845  }
846  return ary;
847  }
848 }
849 
850 /*
851  * See <tt>Dir.getwd</tt>. Returns the current working directory as a Pathname.
852  */
853 static VALUE
855 {
856  VALUE str;
857  str = rb_funcall(rb_cDir, rb_intern("getwd"), 0);
858  return rb_class_new_instance(1, &str, klass);
859 }
860 
861 /*
862  * Return the entries (files and subdirectories) in the directory, each as a
863  * Pathname object.
864  *
865  * The result may contain the current directory #<Pathname:.> and the parent
866  * directory #<Pathname:..>.
867  */
868 static VALUE
870 {
871  VALUE klass, str, ary;
872  long i;
873  klass = rb_obj_class(self);
874  str = get_strpath(self);
875  ary = rb_funcall(rb_cDir, rb_intern("entries"), 1, str);
876  ary = rb_convert_type(ary, T_ARRAY, "Array", "to_ary");
877  for (i = 0; i < RARRAY_LEN(ary); i++) {
878  VALUE elt = RARRAY_PTR(ary)[i];
879  elt = rb_class_new_instance(1, &elt, klass);
880  rb_ary_store(ary, i, elt);
881  }
882  return ary;
883 }
884 
885 /*
886  * See <tt>Dir.mkdir</tt>. Create the referenced directory.
887  */
888 static VALUE
890 {
891  VALUE str = get_strpath(self);
892  VALUE vmode;
893  if (rb_scan_args(argc, argv, "01", &vmode) == 0)
894  return rb_funcall(rb_cDir, rb_intern("mkdir"), 1, str);
895  else
896  return rb_funcall(rb_cDir, rb_intern("mkdir"), 2, str, vmode);
897 }
898 
899 /*
900  * See <tt>Dir.rmdir</tt>. Remove the referenced directory.
901  */
902 static VALUE
904 {
905  return rb_funcall(rb_cDir, rb_intern("rmdir"), 1, get_strpath(self));
906 }
907 
908 /*
909  * See <tt>Dir.open</tt>.
910  */
911 static VALUE
913 {
914  VALUE args[1];
915 
916  args[0] = get_strpath(self);
917  return rb_block_call(rb_cDir, rb_intern("open"), 1, args, 0, 0);
918 }
919 
920 static VALUE
922 {
923  return rb_yield(rb_class_new_instance(1, &elt, klass));
924 }
925 
926 /*
927  * Iterates over the entries (files and subdirectories) in the directory. It
928  * yields a Pathname object for each entry.
929  *
930  * This method has available since 1.8.1.
931  */
932 static VALUE
934 {
935  VALUE args[1];
936 
937  args[0] = get_strpath(self);
938  return rb_block_call(rb_cDir, rb_intern("foreach"), 1, args, each_entry_i, rb_obj_class(self));
939 }
940 
941 static VALUE
943 {
944  return rb_funcall(rb_cDir, rb_intern("unlink"), 1, str);
945 }
946 
947 static VALUE
949 {
950  return rb_funcall(rb_cFile, rb_intern("unlink"), 1, str);
951 }
952 
953 /*
954  * Removes a file or directory, using <tt>File.unlink</tt> or
955  * <tt>Dir.unlink</tt> as necessary.
956  */
957 static VALUE
959 {
960  VALUE eENOTDIR = rb_const_get_at(rb_mErrno, rb_intern("ENOTDIR"));
961  VALUE str = get_strpath(self);
962  return rb_rescue2(unlink_body, str, unlink_rescue, str, eENOTDIR, (VALUE)0);
963 }
964 
965 /*
966  * create a pathname object.
967  *
968  * This method is available since 1.8.5.
969  */
970 static VALUE
972 {
973  return rb_class_new_instance(1, &str, rb_cPathname);
974 }
975 
976 /*
977  * == Pathname
978  *
979  * Pathname represents a pathname which locates a file in a filesystem.
980  * The pathname depends on OS: Unix, Windows, etc.
981  * Pathname library works with pathnames of local OS.
982  * However non-Unix pathnames are supported experimentally.
983  *
984  * It does not represent the file itself.
985  * A Pathname can be relative or absolute. It's not until you try to
986  * reference the file that it even matters whether the file exists or not.
987  *
988  * Pathname is immutable. It has no method for destructive update.
989  *
990  * The value of this class is to manipulate file path information in a neater
991  * way than standard Ruby provides. The examples below demonstrate the
992  * difference. *All* functionality from File, FileTest, and some from Dir and
993  * FileUtils is included, in an unsurprising way. It is essentially a facade for
994  * all of these, and more.
995  *
996  * == Examples
997  *
998  * === Example 1: Using Pathname
999  *
1000  * require 'pathname'
1001  * pn = Pathname.new("/usr/bin/ruby")
1002  * size = pn.size # 27662
1003  * isdir = pn.directory? # false
1004  * dir = pn.dirname # Pathname:/usr/bin
1005  * base = pn.basename # Pathname:ruby
1006  * dir, base = pn.split # [Pathname:/usr/bin, Pathname:ruby]
1007  * data = pn.read
1008  * pn.open { |f| _ }
1009  * pn.each_line { |line| _ }
1010  *
1011  * === Example 2: Using standard Ruby
1012  *
1013  * pn = "/usr/bin/ruby"
1014  * size = File.size(pn) # 27662
1015  * isdir = File.directory?(pn) # false
1016  * dir = File.dirname(pn) # "/usr/bin"
1017  * base = File.basename(pn) # "ruby"
1018  * dir, base = File.split(pn) # ["/usr/bin", "ruby"]
1019  * data = File.read(pn)
1020  * File.open(pn) { |f| _ }
1021  * File.foreach(pn) { |line| _ }
1022  *
1023  * === Example 3: Special features
1024  *
1025  * p1 = Pathname.new("/usr/lib") # Pathname:/usr/lib
1026  * p2 = p1 + "ruby/1.8" # Pathname:/usr/lib/ruby/1.8
1027  * p3 = p1.parent # Pathname:/usr
1028  * p4 = p2.relative_path_from(p3) # Pathname:lib/ruby/1.8
1029  * pwd = Pathname.pwd # Pathname:/home/gavin
1030  * pwd.absolute? # true
1031  * p5 = Pathname.new "." # Pathname:.
1032  * p5 = p5 + "music/../articles" # Pathname:music/../articles
1033  * p5.cleanpath # Pathname:articles
1034  * p5.realpath # Pathname:/home/gavin/articles
1035  * p5.children # [Pathname:/home/gavin/articles/linux, ...]
1036  *
1037  * == Breakdown of functionality
1038  *
1039  * === Core methods
1040  *
1041  * These methods are effectively manipulating a String, because that's
1042  * all a path is. Except for #mountpoint?, #children, #each_child,
1043  * #realdirpath and #realpath, they don't access the filesystem.
1044  *
1045  * - +
1046  * - #join
1047  * - #parent
1048  * - #root?
1049  * - #absolute?
1050  * - #relative?
1051  * - #relative_path_from
1052  * - #each_filename
1053  * - #cleanpath
1054  * - #realpath
1055  * - #realdirpath
1056  * - #children
1057  * - #each_child
1058  * - #mountpoint?
1059  *
1060  * === File status predicate methods
1061  *
1062  * These methods are a facade for FileTest:
1063  * - #blockdev?
1064  * - #chardev?
1065  * - #directory?
1066  * - #executable?
1067  * - #executable_real?
1068  * - #exist?
1069  * - #file?
1070  * - #grpowned?
1071  * - #owned?
1072  * - #pipe?
1073  * - #readable?
1074  * - #world_readable?
1075  * - #readable_real?
1076  * - #setgid?
1077  * - #setuid?
1078  * - #size
1079  * - #size?
1080  * - #socket?
1081  * - #sticky?
1082  * - #symlink?
1083  * - #writable?
1084  * - #world_writable?
1085  * - #writable_real?
1086  * - #zero?
1087  *
1088  * === File property and manipulation methods
1089  *
1090  * These methods are a facade for File:
1091  * - #atime
1092  * - #ctime
1093  * - #mtime
1094  * - #chmod(mode)
1095  * - #lchmod(mode)
1096  * - #chown(owner, group)
1097  * - #lchown(owner, group)
1098  * - #fnmatch(pattern, *args)
1099  * - #fnmatch?(pattern, *args)
1100  * - #ftype
1101  * - #make_link(old)
1102  * - #open(*args, &block)
1103  * - #readlink
1104  * - #rename(to)
1105  * - #stat
1106  * - #lstat
1107  * - #make_symlink(old)
1108  * - #truncate(length)
1109  * - #utime(atime, mtime)
1110  * - #basename(*args)
1111  * - #dirname
1112  * - #extname
1113  * - #expand_path(*args)
1114  * - #split
1115  *
1116  * === Directory methods
1117  *
1118  * These methods are a facade for Dir:
1119  * - Pathname.glob(*args)
1120  * - Pathname.getwd / Pathname.pwd
1121  * - #rmdir
1122  * - #entries
1123  * - #each_entry(&block)
1124  * - #mkdir(*args)
1125  * - #opendir(*args)
1126  *
1127  * === IO
1128  *
1129  * These methods are a facade for IO:
1130  * - #each_line(*args, &block)
1131  * - #read(*args)
1132  * - #binread(*args)
1133  * - #readlines(*args)
1134  * - #sysopen(*args)
1135  *
1136  * === Utilities
1137  *
1138  * These methods are a mixture of Find, FileUtils, and others:
1139  * - #find(&block)
1140  * - #mkpath
1141  * - #rmtree
1142  * - #unlink / #delete
1143  *
1144  *
1145  * == Method documentation
1146  *
1147  * As the above section shows, most of the methods in Pathname are facades. The
1148  * documentation for these methods generally just says, for instance, "See
1149  * FileTest.writable?", as you should be familiar with the original method
1150  * anyway, and its documentation (e.g. through +ri+) will contain more
1151  * information. In some cases, a brief description will follow.
1152  */
1153 void
1155 {
1156  id_at_path = rb_intern("@path");
1157  id_to_path = rb_intern("to_path");
1158 
1159  rb_cPathname = rb_define_class("Pathname", rb_cObject);
1160  rb_define_method(rb_cPathname, "initialize", path_initialize, 1);
1161  rb_define_method(rb_cPathname, "freeze", path_freeze, 0);
1163  rb_define_method(rb_cPathname, "untaint", path_untaint, 0);
1166  rb_define_method(rb_cPathname, "eql?", path_eq, 1);
1170  rb_define_method(rb_cPathname, "to_path", path_to_s, 0);
1171  rb_define_method(rb_cPathname, "inspect", path_inspect, 0);
1172  rb_define_method(rb_cPathname, "sub", path_sub, -1);
1173  rb_define_method(rb_cPathname, "sub_ext", path_sub_ext, 1);
1174  rb_define_method(rb_cPathname, "realpath", path_realpath, -1);
1175  rb_define_method(rb_cPathname, "realdirpath", path_realdirpath, -1);
1176  rb_define_method(rb_cPathname, "each_line", path_each_line, -1);
1177  rb_define_method(rb_cPathname, "read", path_read, -1);
1178  rb_define_method(rb_cPathname, "binread", path_binread, -1);
1179  rb_define_method(rb_cPathname, "readlines", path_readlines, -1);
1180  rb_define_method(rb_cPathname, "sysopen", path_sysopen, -1);
1185  rb_define_method(rb_cPathname, "lchmod", path_lchmod, 1);
1187  rb_define_method(rb_cPathname, "lchown", path_lchown, 2);
1188  rb_define_method(rb_cPathname, "fnmatch", path_fnmatch, -1);
1189  rb_define_method(rb_cPathname, "fnmatch?", path_fnmatch, -1);
1191  rb_define_method(rb_cPathname, "make_link", path_make_link, 1);
1192  rb_define_method(rb_cPathname, "open", path_open, -1);
1193  rb_define_method(rb_cPathname, "readlink", path_readlink, 0);
1194  rb_define_method(rb_cPathname, "rename", path_rename, 1);
1197  rb_define_method(rb_cPathname, "make_symlink", path_make_symlink, 1);
1198  rb_define_method(rb_cPathname, "truncate", path_truncate, 1);
1200  rb_define_method(rb_cPathname, "basename", path_basename, -1);
1201  rb_define_method(rb_cPathname, "dirname", path_dirname, 0);
1202  rb_define_method(rb_cPathname, "extname", path_extname, 0);
1203  rb_define_method(rb_cPathname, "expand_path", path_expand_path, -1);
1205  rb_define_method(rb_cPathname, "blockdev?", path_blockdev_p, 0);
1206  rb_define_method(rb_cPathname, "chardev?", path_chardev_p, 0);
1207  rb_define_method(rb_cPathname, "executable?", path_executable_p, 0);
1208  rb_define_method(rb_cPathname, "executable_real?", path_executable_real_p, 0);
1210  rb_define_method(rb_cPathname, "grpowned?", path_grpowned_p, 0);
1211  rb_define_method(rb_cPathname, "directory?", path_directory_p, 0);
1216  rb_define_method(rb_cPathname, "readable?", path_readable_p, 0);
1217  rb_define_method(rb_cPathname, "world_readable?", path_world_readable_p, 0);
1218  rb_define_method(rb_cPathname, "readable_real?", path_readable_real_p, 0);
1224  rb_define_method(rb_cPathname, "symlink?", path_symlink_p, 0);
1225  rb_define_method(rb_cPathname, "writable?", path_writable_p, 0);
1226  rb_define_method(rb_cPathname, "world_writable?", path_world_writable_p, 0);
1227  rb_define_method(rb_cPathname, "writable_real?", path_writable_real_p, 0);
1232  rb_define_method(rb_cPathname, "entries", path_entries, 0);
1233  rb_define_method(rb_cPathname, "mkdir", path_mkdir, -1);
1235  rb_define_method(rb_cPathname, "opendir", path_opendir, 0);
1236  rb_define_method(rb_cPathname, "each_entry", path_each_entry, 0);
1237  rb_define_method(rb_cPathname, "unlink", path_unlink, 0);
1238  rb_define_method(rb_cPathname, "delete", path_unlink, 0);
1241 }
#define RSTRING_LEN(string)
Definition: generator.h:45
RARRAY_PTR(q->result)[0]
ssize_t n
Definition: bigdecimal.c:5519
volatile VALUE ary
Definition: tcltklib.c:9700
static VALUE unlink_rescue(VALUE str, VALUE errinfo)
Definition: pathname.c:948
static VALUE path_world_writable_p(VALUE self)
Definition: pathname.c:794
VALUE rb_ary_entry(VALUE ary, long offset)
Definition: array.c:956
VALUE rb_str_equal(VALUE str1, VALUE str2)
Definition: string.c:2284
static VALUE path_owned_p(VALUE self)
Definition: pathname.c:695
static VALUE path_zero_p(VALUE self)
Definition: pathname.c:812
static VALUE path_mkdir(int argc, VALUE *argv, VALUE self)
Definition: pathname.c:889
static VALUE path_pipe_p(VALUE self)
Definition: pathname.c:677
static VALUE path_writable_p(VALUE self)
Definition: pathname.c:785
static VALUE path_size(VALUE self)
Definition: pathname.c:749
static VALUE path_rmdir(VALUE self)
Definition: pathname.c:903
parser parser_yylval val
Definition: ripper.c:14289
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
Definition: class.c:1343
static VALUE path_readable_real_p(VALUE self)
Definition: pathname.c:722
static VALUE path_readable_p(VALUE self)
Definition: pathname.c:704
#define rb_block_call(arg1, arg2, arg3, arg4, arg5, arg6)
Definition: ruby_missing.h:38
static VALUE path_executable_real_p(VALUE self)
Definition: pathname.c:632
static VALUE path_socket_p(VALUE self)
Definition: pathname.c:686
SYMID SyckParser * p
Definition: yaml2byte.c:119
static VALUE path_atime(VALUE self)
Definition: pathname.c:346
VALUE rb_eTypeError
Definition: error.c:467
static VALUE path_each_entry(VALUE self)
Definition: pathname.c:933
unsigned long VALUE
Definition: ruby.h:88
static VALUE path_to_s(VALUE self)
Definition: pathname.c:140
VALUE rb_cFile
Definition: file.c:131
static VALUE get_strpath(VALUE obj)
Definition: pathname.c:8
static void VALUE * p2
Definition: array.c:1848
#define RSTRING_PTR(string)
Definition: generator.h:42
static VALUE path_fnmatch(int argc, VALUE *argv, VALUE self)
Definition: pathname.c:414
void rb_raise(VALUE exc, const char *fmt,...)
Definition: error.c:1574
VALUE rb_ivar_get(VALUE, ID)
Definition: variable.c:1026
static void VALUE * p1
Definition: array.c:1848
VALUE rb_mFileTest
Definition: file.c:132
static VALUE path_chardev_p(VALUE self)
Definition: pathname.c:614
VALUE rb_convert_type(VALUE, int, const char *, const char *)
Definition: object.c:2079
static VALUE path_ctime(VALUE self)
Definition: pathname.c:355
VALUE rb_obj_is_kind_of(VALUE, VALUE)
Definition: object.c:525
static VALUE path_taint(VALUE self)
Definition: pathname.c:58
st_index_t rb_str_hash(VALUE)
Definition: string.c:2170
#define RARRAY_LEN(ARRAY)
Definition: generator.h:39
VALUE rb_ary_new3(long n,...)
Definition: array.c:347
static VALUE path_read(int argc, VALUE *argv, VALUE self)
Definition: pathname.c:275
return str
Definition: ruby.c:1183
#define T_ARRAY
Definition: ruby.h:420
static VALUE glob_i(VALUE elt, VALUE klass, int argc, VALUE *argv)
Definition: pathname.c:818
static VALUE path_opendir(VALUE self)
Definition: pathname.c:912
void rb_define_global_function(const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a global function.
Definition: class.c:1372
static VALUE path_executable_p(VALUE self)
Definition: pathname.c:623
static VALUE path_chmod(VALUE self, VALUE mode)
Definition: pathname.c:373
static VALUE path_f_pathname(VALUE self, VALUE str)
Definition: pathname.c:971
static VALUE path_s_getwd(VALUE klass)
Definition: pathname.c:854
VALUE VALUE args
Definition: tcltklib.c:2550
void rb_undef_method(VALUE klass, const char *name)
Definition: class.c:1228
const char * rb_obj_classname(VALUE)
Definition: variable.c:318
static VALUE path_realdirpath(int argc, VALUE *argv, VALUE self)
Definition: pathname.c:228
VALUE rb_obj_untaint(VALUE)
Definition: object.c:810
static VALUE path_make_link(VALUE self, VALUE old)
Definition: pathname.c:441
#define Qnil
Definition: ruby.h:367
static VALUE path_lchmod(VALUE self, VALUE mode)
Definition: pathname.c:382
VALUE rb_obj_dup(VALUE)
Definition: object.c:315
return rb_str_append(rb_str_new2(cmd_id_head), id_num)
static VALUE path_truncate(VALUE self, VALUE length)
Definition: pathname.c:519
static VALUE path_sticky_p(VALUE self)
Definition: pathname.c:767
n NULL
Definition: yaml2byte.c:134
static VALUE path_eq(VALUE self, VALUE other)
Definition: pathname.c:79
VALUE rb_class_new_instance(int, VALUE *, VALUE)
Definition: object.c:1639
return Qfalse
Definition: tcltklib.c:6768
int rb_block_given_p(void)
Definition: eval.c:604
VALUE rb_obj_taint(VALUE)
Definition: object.c:791
static VALUE unlink_body(VALUE str)
Definition: pathname.c:942
RUBY_EXTERN VALUE rb_cObject
Definition: ruby.h:1246
static VALUE path_setgid_p(VALUE self)
Definition: pathname.c:740
int flags
Definition: tcltklib.c:3012
static VALUE path_hash(VALUE self)
Definition: pathname.c:125
static VALUE path_file_p(VALUE self)
Definition: pathname.c:668
static VALUE path_entries(VALUE self)
Definition: pathname.c:869
VALUE rb_define_class(const char *name, VALUE super)
Defines a top-level class.
Definition: class.c:469
static VALUE VALUE obj
Definition: tcltklib.c:3147
static VALUE path_exist_p(VALUE self)
Definition: pathname.c:641
void rb_ary_store(VALUE ary, long idx, VALUE val)
Definition: array.c:635
static VALUE path_readlink(VALUE self)
Definition: pathname.c:469
static VALUE path_extname(VALUE self)
Definition: pathname.c:563
#define TYPE(x)
Definition: ruby.h:441
static VALUE path_unlink(VALUE self)
Definition: pathname.c:958
static VALUE each_entry_i(VALUE elt, VALUE klass, int argc, VALUE *argv)
Definition: pathname.c:921
static VALUE path_inspect(VALUE self)
Definition: pathname.c:147
VALUE rb_mErrno
Definition: error.c:486
static VALUE path_untaint(VALUE self)
Definition: pathname.c:66
static VALUE rb_cPathname
Definition: pathname.c:4
static VALUE path_dirname(VALUE self)
Definition: pathname.c:552
static VALUE path_make_symlink(VALUE self, VALUE old)
Definition: pathname.c:510
VALUE * argv
Definition: tcltklib.c:1962
VALUE rb_str_subseq(VALUE, long, long)
Definition: string.c:1609
RUBY_EXTERN VALUE rb_cIO
Definition: ruby.h:1262
VALUE rb_yield(VALUE)
Definition: vm_eval.c:781
static VALUE path_readlines(int argc, VALUE *argv, VALUE self)
Definition: pathname.c:314
VALUE rb_check_funcall(VALUE, ID, int, VALUE *)
Definition: vm_eval.c:312
VALUE rb_funcall2(VALUE, ID, int, const VALUE *)
Calls a method.
Definition: vm_eval.c:669
VALUE rb_sprintf(const char *format,...)
Definition: sprintf.c:1203
static void set_strpath(VALUE obj, VALUE val)
Definition: pathname.c:18
VALUE mode
Definition: tcltklib.c:1655
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
Definition: class.c:1416
static VALUE path_grpowned_p(VALUE self)
Definition: pathname.c:650
size_t length
Definition: tcltklib.c:4548
unsigned long ID
Definition: ruby.h:89
VALUE rb_cDir
Definition: dir.c:321
static VALUE path_writable_real_p(VALUE self)
Definition: pathname.c:803
static VALUE path_size_p(VALUE self)
Definition: pathname.c:758
int argc
Definition: tcltklib.c:1961
static VALUE path_world_readable_p(VALUE self)
Definition: pathname.c:713
VALUE rb_rescue2(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*r_proc)(ANYARGS), VALUE data2,...)
Definition: eval.c:634
VALUE rb_call_super(int, const VALUE *)
Definition: vm_eval.c:189
static VALUE path_each_line(int argc, VALUE *argv, VALUE self)
Definition: pathname.c:250
static VALUE path_freeze(VALUE self)
Definition: pathname.c:50
VpDivd * c
Definition: bigdecimal.c:1163
static VALUE path_lchown(VALUE self, VALUE owner, VALUE group)
Definition: pathname.c:400
static VALUE path_ftype(VALUE self)
Definition: pathname.c:429
VALUE rb_str_freeze(VALUE)
Definition: string.c:1723
void Init_pathname()
Definition: pathname.c:1154
arg
Definition: ripper.y:1287
static VALUE path_sub(int argc, VALUE *argv, VALUE self)
Definition: pathname.c:158
static VALUE path_lstat(VALUE self)
Definition: pathname.c:498
rb_encoding * rb_enc_get(VALUE obj)
Definition: encoding.c:733
#define INT2FIX(i)
Definition: ruby.h:225
static VALUE path_binread(int argc, VALUE *argv, VALUE self)
Definition: pathname.c:294
static VALUE path_directory_p(VALUE self)
Definition: pathname.c:659
static VALUE path_utime(VALUE self, VALUE atime, VALUE mtime)
Definition: pathname.c:528
static VALUE path_basename(int argc, VALUE *argv, VALUE self)
Definition: pathname.c:537
static VALUE path_blockdev_p(VALUE self)
Definition: pathname.c:605
static VALUE path_split(VALUE self)
Definition: pathname.c:588
VALUE rb_check_array_type(VALUE ary)
Definition: array.c:472
static VALUE path_rename(VALUE self, VALUE to)
Definition: pathname.c:480
rb_ivar_set(einfo, ID_at_interp, interp)
static ID id_to_path
Definition: pathname.c:5
#define T_STRING
Definition: ruby.h:418
klass
Definition: tcltklib.c:3493
static VALUE path_open(int argc, VALUE *argv, VALUE self)
Definition: pathname.c:450
static ID id_at_path
Definition: pathname.c:5
static VALUE path_expand_path(int argc, VALUE *argv, VALUE self)
Definition: pathname.c:573
#define OBJ_INFECT(x, s)
Definition: ruby.h:967
static VALUE path_s_glob(int argc, VALUE *argv, VALUE klass)
Definition: pathname.c:827
static VALUE path_cmp(VALUE self, VALUE other)
Definition: pathname.c:90
static VALUE path_sysopen(int argc, VALUE *argv, VALUE self)
Definition: pathname.c:332
static VALUE path_sub_ext(VALUE self, VALUE repl)
Definition: pathname.c:178
VALUE rb_const_get_at(VALUE, ID)
Definition: variable.c:1641
static VALUE path_setuid_p(VALUE self)
Definition: pathname.c:731
return rb_funcall(q->proc, ID_call, 0)
static VALUE path_symlink_p(VALUE self)
Definition: pathname.c:776
ssize_t i
Definition: bigdecimal.c:5519
#define rb_intern(str)
const char * ruby_enc_find_extname(const char *name, long *len, rb_encoding *enc)
Definition: file.c:3804
static VALUE path_stat(VALUE self)
Definition: pathname.c:489
#define Qundef
Definition: ruby.h:368
static VALUE path_realpath(int argc, VALUE *argv, VALUE self)
Definition: pathname.c:213
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
Definition: class.c:1210
static VALUE path_mtime(VALUE self)
Definition: pathname.c:364
static VALUE path_initialize(VALUE self, VALUE arg)
Definition: pathname.c:28
VALUE rb_eArgError
Definition: error.c:468
static VALUE path_chown(VALUE self, VALUE owner, VALUE group)
Definition: pathname.c:391
#define StringValue(v)
Definition: ruby.h:466
gz mtime
Definition: zlib.c:2026
VALUE rb_obj_class(VALUE)
Definition: object.c:177