smb 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,13 +19,23 @@ end
19
19
  # Look for headers in {gem_root}/ext/{package}
20
20
  if use_gems
21
21
  %w[
22
- gdk_pixbuf2 atk gtk2 ].each do |package|
23
- require package
24
- $CFLAGS += " -I"+Gem.loaded_specs[package].full_gem_path+"/ext/"+package
22
+ gdk_pixbuf2 atk gtk2].each do |package|
23
+ require package
24
+ if Gem.loaded_specs[package]
25
+ $CFLAGS += " -I" + Gem.loaded_specs[package].full_gem_path + "/ext/" + package
26
+ else
27
+ if fn = $".find { |n| n.sub(/[.](so|rb)$/,'') == package }
28
+ dr = $:.find { |d| File.exist?(File.join(d, fn)) }
29
+ pt = File.join(dr,fn) if dr && fn
30
+ else
31
+ pt = "??"
32
+ end
33
+ STDERR.puts "require '" + package + "' loaded '"+pt+"' instead of the gem - trying to continue, but build may fail"
34
+ end
25
35
  end
26
36
  end
27
37
  if RbConfig::CONFIG.has_key?('rubyhdrdir')
28
- $CFLAGS += " -I" + RbConfig::CONFIG['rubyhdrdir']+'/ruby'
38
+ $CFLAGS += " -I" + RbConfig::CONFIG['rubyhdrdir']+'/ruby'
29
39
  end
30
40
 
31
41
  $CFLAGS += " -I."
@@ -111,7 +111,11 @@ static VALUE rubber_enum_cmp(VALUE value, VALUE other)
111
111
  VALUE a,b;
112
112
  a = rb_funcall(value, rb_intern("to_i"), 0);
113
113
  b = rb_funcall(other, rb_intern("to_i"), 0);
114
+ #ifdef RB_NUM_COERCE_FUNCS_NEED_OPID
115
+ return rb_num_coerce_cmp(a, b, rb_intern("=="));
116
+ #else
114
117
  return rb_num_coerce_cmp(a, b);
118
+ #endif
115
119
  }
116
120
 
117
121
  static VALUE rubber_enum_to_i(VALUE value)
@@ -210,6 +214,39 @@ static VALUE
210
214
  Dir_url(VALUE self);
211
215
  static VALUE
212
216
  Dir_close(VALUE self);
217
+ static VALUE cStat;
218
+ static VALUE
219
+ Stat_exist_query(VALUE self);
220
+ static VALUE
221
+ Stat_dev(VALUE self);
222
+ static VALUE
223
+ Stat_ino(VALUE self);
224
+ static VALUE
225
+ Stat_mode(VALUE self);
226
+ static VALUE
227
+ Stat_nlink(VALUE self);
228
+ static VALUE
229
+ Stat_uid(VALUE self);
230
+ static VALUE
231
+ Stat_gid(VALUE self);
232
+ static VALUE
233
+ Stat_rdev(VALUE self);
234
+ static VALUE
235
+ Stat_blksize(VALUE self);
236
+ static VALUE
237
+ Stat_blocks(VALUE self);
238
+ static VALUE
239
+ Stat_size(VALUE self);
240
+ static VALUE
241
+ Stat_directory_query(VALUE self);
242
+ static VALUE
243
+ Stat_file_query(VALUE self);
244
+ static VALUE
245
+ Stat_regular_query(VALUE self);
246
+ static VALUE
247
+ Stat_symlink_query(VALUE self);
248
+ static VALUE
249
+ Stat_fifo_query(VALUE self);
213
250
  static VALUE cFile;
214
251
  static VALUE
215
252
  File_CLASS_new(VALUE self, VALUE __v_url, VALUE __v_flags, VALUE __v_mode);
@@ -246,8 +283,8 @@ File_CLASS_read(VALUE self, VALUE __v_url);
246
283
  static volatile VALUE auth_block = Qnil;
247
284
 
248
285
  static void smbc_get_auth_data(const char *srv, const char *shr,
249
- char *wg, int wglen,
250
- char *un, int unlen,
286
+ char *wg, int wglen,
287
+ char *un, int unlen,
251
288
  char *pw, int pwlen)
252
289
  {
253
290
  volatile VALUE ret= Qnil;
@@ -301,7 +338,7 @@ static VALUE stat_new(struct stat *st)
301
338
  nst = ALLOC(struct stat);
302
339
  *nst = *st;
303
340
  }
304
- return Data_Wrap_Struct(rb_cStat, NULL, free, nst);
341
+ return Data_Wrap_Struct(cStat, NULL, free, nst);
305
342
  }
306
343
 
307
344
 
@@ -348,7 +385,7 @@ SMB_CLASS_init(int __p_argc, VALUE *__p_argv, VALUE self)
348
385
  debug = 0;
349
386
 
350
387
 
351
- #line 130 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
388
+ #line 129 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
352
389
  auth_block = block;
353
390
  rb_gc_register_address(&auth_block);
354
391
  if (smbc_init(smbc_get_auth_data, debug) < 0) { rb_sys_fail("smbc_init failed");
@@ -378,8 +415,7 @@ CTX_CLASS___alloc__(VALUE self)
378
415
  SMBCCTX * ctx =
379
416
  smbc_new_context();
380
417
  volatile VALUE obj ;
381
- rb_p(self);
382
- obj = Data_Wrap_Struct(self, NULL, smbc_free_context, ctx);
418
+ obj = Data_Wrap_Struct(self, NULL, smbc_free_context, ctx);
383
419
  do { __p_retval = obj; goto out; } while(0);
384
420
 
385
421
  } while(0);
@@ -393,7 +429,7 @@ CTX_initialize(VALUE self)
393
429
  {
394
430
  SMBCCTX *ctx; Data_Get_Struct(self, SMBCCTX, ctx);
395
431
 
396
- #line 100 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
432
+ #line 99 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
397
433
  smbc_init_context(ctx);
398
434
 
399
435
  return Qnil;
@@ -421,7 +457,7 @@ SMBCCTX *ctx; Data_Get_Struct(self, SMBCCTX, ctx);
421
457
  mode = 0666;
422
458
 
423
459
 
424
- #line 106 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
460
+ #line 105 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
425
461
 
426
462
  do {
427
463
  volatile VALUE rfile ;
@@ -465,7 +501,7 @@ SMBCCTX *ctx; Data_Get_Struct(self, SMBCCTX, ctx);
465
501
  mode = 0666;
466
502
 
467
503
 
468
- #line 112 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
504
+ #line 111 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
469
505
 
470
506
  do {
471
507
  volatile VALUE rfile ;
@@ -488,7 +524,7 @@ SMBCCTX *ctx; Data_Get_Struct(self, SMBCCTX, ctx);
488
524
  Check_Type(sfile, T_DATA);
489
525
  Check_Type(data, T_STRING);
490
526
 
491
- #line 118 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
527
+ #line 117 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
492
528
 
493
529
  do {
494
530
  SMBCFILE * file ;
@@ -508,7 +544,7 @@ CTX_file_close(VALUE self, VALUE sfile)
508
544
  SMBCCTX *ctx; Data_Get_Struct(self, SMBCCTX, ctx);
509
545
  Check_Type(sfile, T_DATA);
510
546
 
511
- #line 123 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
547
+ #line 122 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
512
548
 
513
549
  do {
514
550
  SMBCFILE * file ;
@@ -528,7 +564,7 @@ Dir_CLASS_new(VALUE self, VALUE __v_url)
528
564
  char * url; char * __orig_url;
529
565
  __orig_url = url = ( NIL_P(__v_url) ? NULL : StringValuePtr(__v_url) );
530
566
 
531
- #line 145 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
567
+ #line 144 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
532
568
 
533
569
  do {
534
570
  volatile VALUE val ;
@@ -552,7 +588,7 @@ Dir_CLASS_rmdir(VALUE self, VALUE __v_url)
552
588
  char * url; char * __orig_url;
553
589
  __orig_url = url = ( NIL_P(__v_url) ? NULL : StringValuePtr(__v_url) );
554
590
 
555
- #line 161 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
591
+ #line 160 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
556
592
  if (smbc_rmdir(url) < 0) rb_sys_fail(url);
557
593
 
558
594
  return Qnil;
@@ -566,7 +602,7 @@ Dir_CLASS_mkdir(VALUE self, VALUE __v_url, VALUE __v_mode)
566
602
  __orig_url = url = ( NIL_P(__v_url) ? NULL : StringValuePtr(__v_url) );
567
603
  __orig_mode = mode = NUM2INT(__v_mode);
568
604
 
569
- #line 165 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
605
+ #line 164 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
570
606
  if (smbc_mkdir(url, mode) < 0) rb_sys_fail(url);
571
607
 
572
608
  return Qnil;
@@ -577,7 +613,7 @@ Dir_initialize(VALUE self)
577
613
  {
578
614
  rb_smbprivate *dir; Data_Get_Struct(self, rb_smbprivate, dir);
579
615
 
580
- #line 172 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
616
+ #line 171 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
581
617
 
582
618
  return Qnil;
583
619
  }
@@ -588,7 +624,7 @@ Dir_read_entry(VALUE self)
588
624
  VALUE __p_retval = Qnil;
589
625
  rb_smbprivate *dir; Data_Get_Struct(self, rb_smbprivate, dir);
590
626
 
591
- #line 174 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
627
+ #line 173 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
592
628
 
593
629
  do {
594
630
  struct smbc_dirent* de ;
@@ -607,7 +643,7 @@ Dir_read(VALUE self)
607
643
  VALUE __p_retval = Qnil;
608
644
  rb_smbprivate *dir; Data_Get_Struct(self, rb_smbprivate, dir);
609
645
 
610
- #line 185 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
646
+ #line 184 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
611
647
 
612
648
  do {
613
649
  struct smbc_dirent* de ;
@@ -626,7 +662,7 @@ Dir_tell(VALUE self)
626
662
  VALUE __p_retval = Qnil;
627
663
  rb_smbprivate *dir; Data_Get_Struct(self, rb_smbprivate, dir);
628
664
 
629
- #line 191 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
665
+ #line 190 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
630
666
  do { __p_retval = INT2NUM(smbc_telldir(dir->handle)); goto out; } while(0);
631
667
  out:
632
668
  return __p_retval;
@@ -638,7 +674,7 @@ Dir_url(VALUE self)
638
674
  VALUE __p_retval = Qnil;
639
675
  rb_smbprivate *dir; Data_Get_Struct(self, rb_smbprivate, dir);
640
676
 
641
- #line 194 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
677
+ #line 193 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
642
678
  do { __p_retval = rb_str_new2(dir->url); goto out; } while(0);
643
679
  out:
644
680
  return __p_retval;
@@ -649,13 +685,205 @@ Dir_close(VALUE self)
649
685
  {
650
686
  rb_smbprivate *dir; Data_Get_Struct(self, rb_smbprivate, dir);
651
687
 
652
- #line 197 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
688
+ #line 196 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
653
689
  smbc_closedir(dir->handle);
654
690
  dir->handle = 0;
655
691
 
656
692
  return Qnil;
657
693
  }
658
694
 
695
+ static VALUE
696
+ Stat_exist_query(VALUE self)
697
+ {
698
+ VALUE __p_retval = Qnil;
699
+ struct stat *s; Data_Get_Struct(self, struct stat, s);
700
+
701
+ #line 204 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
702
+ do { __p_retval = (((!!s)) ? Qtrue : Qfalse); goto out; } while(0);
703
+ out:
704
+ return __p_retval;
705
+ }
706
+
707
+ static VALUE
708
+ Stat_dev(VALUE self)
709
+ {
710
+ VALUE __p_retval = Qnil;
711
+ struct stat *s; Data_Get_Struct(self, struct stat, s);
712
+
713
+ #line 207 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
714
+ do { __p_retval = LONG2NUM(s->st_dev); goto out; } while(0);
715
+ out:
716
+ return __p_retval;
717
+ }
718
+
719
+ static VALUE
720
+ Stat_ino(VALUE self)
721
+ {
722
+ VALUE __p_retval = Qnil;
723
+ struct stat *s; Data_Get_Struct(self, struct stat, s);
724
+
725
+ #line 210 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
726
+ do { __p_retval = LONG2NUM(s->st_ino); goto out; } while(0);
727
+ out:
728
+ return __p_retval;
729
+ }
730
+
731
+ static VALUE
732
+ Stat_mode(VALUE self)
733
+ {
734
+ VALUE __p_retval = Qnil;
735
+ struct stat *s; Data_Get_Struct(self, struct stat, s);
736
+
737
+ #line 213 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
738
+ do { __p_retval = LONG2NUM(s->st_mode); goto out; } while(0);
739
+ out:
740
+ return __p_retval;
741
+ }
742
+
743
+ static VALUE
744
+ Stat_nlink(VALUE self)
745
+ {
746
+ VALUE __p_retval = Qnil;
747
+ struct stat *s; Data_Get_Struct(self, struct stat, s);
748
+
749
+ #line 216 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
750
+ do { __p_retval = LONG2NUM(s->st_nlink); goto out; } while(0);
751
+ out:
752
+ return __p_retval;
753
+ }
754
+
755
+ static VALUE
756
+ Stat_uid(VALUE self)
757
+ {
758
+ VALUE __p_retval = Qnil;
759
+ struct stat *s; Data_Get_Struct(self, struct stat, s);
760
+
761
+ #line 220 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
762
+ do { __p_retval = LONG2NUM(s->st_uid); goto out; } while(0);
763
+ out:
764
+ return __p_retval;
765
+ }
766
+
767
+ static VALUE
768
+ Stat_gid(VALUE self)
769
+ {
770
+ VALUE __p_retval = Qnil;
771
+ struct stat *s; Data_Get_Struct(self, struct stat, s);
772
+
773
+ #line 223 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
774
+ do { __p_retval = LONG2NUM(s->st_gid); goto out; } while(0);
775
+ out:
776
+ return __p_retval;
777
+ }
778
+
779
+ static VALUE
780
+ Stat_rdev(VALUE self)
781
+ {
782
+ VALUE __p_retval = Qnil;
783
+ struct stat *s; Data_Get_Struct(self, struct stat, s);
784
+
785
+ #line 226 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
786
+ do { __p_retval = LONG2NUM(s->st_rdev); goto out; } while(0);
787
+ out:
788
+ return __p_retval;
789
+ }
790
+
791
+ static VALUE
792
+ Stat_blksize(VALUE self)
793
+ {
794
+ VALUE __p_retval = Qnil;
795
+ struct stat *s; Data_Get_Struct(self, struct stat, s);
796
+
797
+ #line 230 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
798
+ do { __p_retval = LONG2NUM(s->st_blksize); goto out; } while(0);
799
+ out:
800
+ return __p_retval;
801
+ }
802
+
803
+ static VALUE
804
+ Stat_blocks(VALUE self)
805
+ {
806
+ VALUE __p_retval = Qnil;
807
+ struct stat *s; Data_Get_Struct(self, struct stat, s);
808
+
809
+ #line 233 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
810
+ do { __p_retval = LONG2NUM(s->st_blocks); goto out; } while(0);
811
+ out:
812
+ return __p_retval;
813
+ }
814
+
815
+ static VALUE
816
+ Stat_size(VALUE self)
817
+ {
818
+ VALUE __p_retval = Qnil;
819
+ struct stat *s; Data_Get_Struct(self, struct stat, s);
820
+
821
+ #line 237 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
822
+ do { __p_retval = LONG2NUM(s->st_size); goto out; } while(0);
823
+ out:
824
+ return __p_retval;
825
+ }
826
+
827
+ static VALUE
828
+ Stat_directory_query(VALUE self)
829
+ {
830
+ VALUE __p_retval = Qnil;
831
+ struct stat *s; Data_Get_Struct(self, struct stat, s);
832
+
833
+ #line 241 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
834
+ do { __p_retval = ((S_ISDIR(s->st_mode)) ? Qtrue : Qfalse); goto out; } while(0);
835
+ out:
836
+ return __p_retval;
837
+ }
838
+
839
+ static VALUE
840
+ Stat_file_query(VALUE self)
841
+ {
842
+ VALUE __p_retval = Qnil;
843
+ struct stat *s; Data_Get_Struct(self, struct stat, s);
844
+
845
+ #line 244 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
846
+ do { __p_retval = ((S_ISREG(s->st_mode)) ? Qtrue : Qfalse); goto out; } while(0);
847
+ out:
848
+ return __p_retval;
849
+ }
850
+
851
+ static VALUE
852
+ Stat_regular_query(VALUE self)
853
+ {
854
+ VALUE __p_retval = Qnil;
855
+ struct stat *s; Data_Get_Struct(self, struct stat, s);
856
+
857
+ #line 247 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
858
+ do { __p_retval = ((S_ISREG(s->st_mode)) ? Qtrue : Qfalse); goto out; } while(0);
859
+ out:
860
+ return __p_retval;
861
+ }
862
+
863
+ static VALUE
864
+ Stat_symlink_query(VALUE self)
865
+ {
866
+ VALUE __p_retval = Qnil;
867
+ struct stat *s; Data_Get_Struct(self, struct stat, s);
868
+
869
+ #line 250 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
870
+ do { __p_retval = ((S_ISLNK(s->st_mode)) ? Qtrue : Qfalse); goto out; } while(0);
871
+ out:
872
+ return __p_retval;
873
+ }
874
+
875
+ static VALUE
876
+ Stat_fifo_query(VALUE self)
877
+ {
878
+ VALUE __p_retval = Qnil;
879
+ struct stat *s; Data_Get_Struct(self, struct stat, s);
880
+
881
+ #line 253 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
882
+ do { __p_retval = ((S_ISFIFO(s->st_mode)) ? Qtrue : Qfalse); goto out; } while(0);
883
+ out:
884
+ return __p_retval;
885
+ }
886
+
659
887
  static VALUE
660
888
  File_CLASS_new(VALUE self, VALUE __v_url, VALUE __v_flags, VALUE __v_mode)
661
889
  {
@@ -667,7 +895,7 @@ File_CLASS_new(VALUE self, VALUE __v_url, VALUE __v_flags, VALUE __v_mode)
667
895
  __orig_flags = flags = NUM2INT(__v_flags);
668
896
  __orig_mode = mode = NUM2INT(__v_mode);
669
897
 
670
- #line 204 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
898
+ #line 259 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
671
899
 
672
900
  do {
673
901
  volatile VALUE val ;
@@ -696,7 +924,7 @@ File_CLASS_create(VALUE self, VALUE __v_url, VALUE __v_mode)
696
924
  __orig_url = url = ( NIL_P(__v_url) ? NULL : StringValuePtr(__v_url) );
697
925
  __orig_mode = mode = NUM2INT(__v_mode);
698
926
 
699
- #line 222 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
927
+ #line 277 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
700
928
 
701
929
  do {
702
930
  volatile VALUE val ;
@@ -722,7 +950,7 @@ File_CLASS_unlink(VALUE self, VALUE __v_url)
722
950
  char * url; char * __orig_url;
723
951
  __orig_url = url = ( NIL_P(__v_url) ? NULL : StringValuePtr(__v_url) );
724
952
 
725
- #line 240 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
953
+ #line 295 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
726
954
  if (smbc_unlink(url) < 0) rb_sys_fail(url);
727
955
 
728
956
  return Qnil;
@@ -736,7 +964,7 @@ File_CLASS_rename(VALUE self, VALUE __v_ourl, VALUE __v_nurl)
736
964
  __orig_ourl = ourl = ( NIL_P(__v_ourl) ? NULL : StringValuePtr(__v_ourl) );
737
965
  __orig_nurl = nurl = ( NIL_P(__v_nurl) ? NULL : StringValuePtr(__v_nurl) );
738
966
 
739
- #line 244 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
967
+ #line 299 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
740
968
  if (smbc_rename(ourl, nurl) < 0) rb_sys_fail(ourl);
741
969
 
742
970
  return Qnil;
@@ -749,7 +977,7 @@ File_CLASS_stat(VALUE self, VALUE __v_url)
749
977
  char * url; char * __orig_url;
750
978
  __orig_url = url = ( NIL_P(__v_url) ? NULL : StringValuePtr(__v_url) );
751
979
 
752
- #line 248 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
980
+ #line 303 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
753
981
 
754
982
  do {
755
983
  struct stat s ;
@@ -767,7 +995,7 @@ File_initialize(VALUE self)
767
995
  {
768
996
  rb_smbprivate *file; Data_Get_Struct(self, rb_smbprivate, file);
769
997
 
770
- #line 257 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
998
+ #line 312 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
771
999
 
772
1000
  return Qnil;
773
1001
  }
@@ -778,7 +1006,7 @@ File_stat(VALUE self)
778
1006
  VALUE __p_retval = Qnil;
779
1007
  rb_smbprivate *file; Data_Get_Struct(self, rb_smbprivate, file);
780
1008
 
781
- #line 259 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
1009
+ #line 314 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
782
1010
 
783
1011
  do {
784
1012
  struct stat s ;
@@ -797,7 +1025,7 @@ File_url(VALUE self)
797
1025
  VALUE __p_retval = Qnil;
798
1026
  rb_smbprivate *file; Data_Get_Struct(self, rb_smbprivate, file);
799
1027
 
800
- #line 265 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
1028
+ #line 320 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
801
1029
  do { __p_retval = rb_str_new2(file->url); goto out; } while(0);
802
1030
  out:
803
1031
  return __p_retval;
@@ -813,7 +1041,7 @@ rb_smbprivate *file; Data_Get_Struct(self, rb_smbprivate, file);
813
1041
  __orig_offset = offset = NUM2OFFT(__v_offset);
814
1042
  __orig_whence = whence = NUM2INT(__v_whence);
815
1043
 
816
- #line 268 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
1044
+ #line 323 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
817
1045
  do { __p_retval = INT2NUM(smbc_lseek(file->handle, offset, whence)); goto out; } while(0);
818
1046
  out:
819
1047
  ;
@@ -838,7 +1066,7 @@ rb_smbprivate *file; Data_Get_Struct(self, rb_smbprivate, file);
838
1066
  bytes_to_read = -1;
839
1067
 
840
1068
 
841
- #line 271 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
1069
+ #line 326 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
842
1070
 
843
1071
  do {
844
1072
  size_t read ;
@@ -872,7 +1100,7 @@ File_write(VALUE self, VALUE buf)
872
1100
  rb_smbprivate *file; Data_Get_Struct(self, rb_smbprivate, file);
873
1101
  Check_Type(buf, T_STRING);
874
1102
 
875
- #line 308 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
1103
+ #line 363 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
876
1104
 
877
1105
  do {
878
1106
  int i ;
@@ -892,7 +1120,7 @@ File_close(VALUE self)
892
1120
  {
893
1121
  rb_smbprivate *file; Data_Get_Struct(self, rb_smbprivate, file);
894
1122
 
895
- #line 316 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
1123
+ #line 371 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
896
1124
  smbc_close(file->handle);
897
1125
  file->handle = 0;
898
1126
 
@@ -906,7 +1134,7 @@ File_CLASS_read(VALUE self, VALUE __v_url)
906
1134
  char * url; char * __orig_url;
907
1135
  __orig_url = url = ( NIL_P(__v_url) ? NULL : StringValuePtr(__v_url) );
908
1136
 
909
- #line 321 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
1137
+ #line 376 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
910
1138
 
911
1139
  do {
912
1140
  size_t read ;
@@ -1002,6 +1230,23 @@ rb_gc_register_address(&_gcpool_Credentials);
1002
1230
  rb_define_method(cDir, "tell", Dir_tell, 0);
1003
1231
  rb_define_method(cDir, "url", Dir_url, 0);
1004
1232
  rb_define_method(cDir, "close", Dir_close, 0);
1233
+ cStat = rb_define_class_under(mSMB, "Stat", rb_cObject);
1234
+ rb_define_method(cStat, "exist?", Stat_exist_query, 0);
1235
+ rb_define_method(cStat, "dev", Stat_dev, 0);
1236
+ rb_define_method(cStat, "ino", Stat_ino, 0);
1237
+ rb_define_method(cStat, "mode", Stat_mode, 0);
1238
+ rb_define_method(cStat, "nlink", Stat_nlink, 0);
1239
+ rb_define_method(cStat, "uid", Stat_uid, 0);
1240
+ rb_define_method(cStat, "gid", Stat_gid, 0);
1241
+ rb_define_method(cStat, "rdev", Stat_rdev, 0);
1242
+ rb_define_method(cStat, "blksize", Stat_blksize, 0);
1243
+ rb_define_method(cStat, "blocks", Stat_blocks, 0);
1244
+ rb_define_method(cStat, "size", Stat_size, 0);
1245
+ rb_define_method(cStat, "directory?", Stat_directory_query, 0);
1246
+ rb_define_method(cStat, "file?", Stat_file_query, 0);
1247
+ rb_define_method(cStat, "regular?", Stat_regular_query, 0);
1248
+ rb_define_method(cStat, "symlink?", Stat_symlink_query, 0);
1249
+ rb_define_method(cStat, "fifo?", Stat_fifo_query, 0);
1005
1250
  cFile = rb_define_class_under(mSMB, "File", rb_cObject);
1006
1251
  rb_define_singleton_method(cFile, "new", File_CLASS_new, 3);
1007
1252
  rb_define_singleton_method(cFile, "create", File_CLASS_create, 2);
@@ -66,7 +66,7 @@ static VALUE stat_new(struct stat *st)
66
66
  nst = ALLOC(struct stat);
67
67
  *nst = *st;
68
68
  }
69
- return Data_Wrap_Struct(rb_cStat, NULL, free, nst);
69
+ return Data_Wrap_Struct(cStat, NULL, free, nst);
70
70
  }
71
71
 
72
72
  %}
@@ -198,6 +198,66 @@ module SMB
198
198
  dir->handle = 0;
199
199
  end
200
200
  end
201
+
202
+ class Stat
203
+ pre_func struct stat *s; Data_Get_Struct(self, struct stat, s);
204
+ def bool:exist?
205
+ return (!!s);
206
+ end
207
+ def long:dev
208
+ return s->st_dev;
209
+ end
210
+ def long:ino
211
+ return s->st_ino;
212
+ end
213
+ def long:mode
214
+ return s->st_mode;
215
+ end
216
+ def long:nlink
217
+ return s->st_nlink;
218
+ end
219
+
220
+ def long:uid
221
+ return s->st_uid;
222
+ end
223
+ def long:gid
224
+ return s->st_gid;
225
+ end
226
+ def long:rdev
227
+ return s->st_rdev;
228
+ end
229
+
230
+ def long:blksize
231
+ return s->st_blksize;
232
+ end
233
+ def long:blocks
234
+ return s->st_blocks;
235
+ end
236
+
237
+ def long:size
238
+ return s->st_size;
239
+ end
240
+
241
+ def bool:directory?
242
+ return S_ISDIR(s->st_mode);
243
+ end
244
+ def bool:file?
245
+ return S_ISREG(s->st_mode);
246
+ end
247
+ def bool:regular?
248
+ return S_ISREG(s->st_mode);
249
+ end
250
+ def bool:symlink?
251
+ return S_ISLNK(s->st_mode);
252
+ end
253
+ def bool:fifo?
254
+ return S_ISFIFO(s->st_mode);
255
+ end
256
+
257
+ def bool:zero?
258
+ return (s->st_size == 0);
259
+ end
260
+ end
201
261
 
202
262
  class File
203
263
  def self.new(char *url, int flags, int mode)
@@ -48,6 +48,39 @@
48
48
 
49
49
  --- SMB::Dir#close
50
50
 
51
+ == class SMB::Stat
52
+ --- SMB::Stat#exist?
53
+
54
+ --- SMB::Stat#dev
55
+
56
+ --- SMB::Stat#ino
57
+
58
+ --- SMB::Stat#mode
59
+
60
+ --- SMB::Stat#nlink
61
+
62
+ --- SMB::Stat#uid
63
+
64
+ --- SMB::Stat#gid
65
+
66
+ --- SMB::Stat#rdev
67
+
68
+ --- SMB::Stat#blksize
69
+
70
+ --- SMB::Stat#blocks
71
+
72
+ --- SMB::Stat#size
73
+
74
+ --- SMB::Stat#directory?
75
+
76
+ --- SMB::Stat#file?
77
+
78
+ --- SMB::Stat#regular?
79
+
80
+ --- SMB::Stat#symlink?
81
+
82
+ --- SMB::Stat#fifo?
83
+
51
84
  == class SMB::File
52
85
  --- SMB::File.new(String url, Integer flags, Integer mode)
53
86
 
@@ -1,4 +1,4 @@
1
1
  module SMB
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
4
4
 
metadata CHANGED
@@ -1,49 +1,41 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: smb
3
- version: !ruby/object:Gem::Version
4
- hash: 11
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.1
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 5
9
- - 0
10
- version: 0.5.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Geoff Youngs
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2013-06-17 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- prerelease: false
22
- requirement: &id001 !ruby/object:Gem::Requirement
12
+ date: 2013-06-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rubber-generate
16
+ requirement: !ruby/object:Gem::Requirement
23
17
  none: false
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- hash: 61
28
- segments:
29
- - 0
30
- - 0
31
- - 17
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
32
21
  version: 0.0.17
33
22
  type: :runtime
34
- name: rubber-generate
35
- version_requirements: *id001
36
- description: |
37
- smb
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.0.17
30
+ description: ! 'smb
38
31
 
32
+ '
39
33
  email: git@intersect-uk.co.uk
40
34
  executables: []
41
-
42
- extensions:
35
+ extensions:
43
36
  - ext/smb/extconf.rb
44
37
  extra_rdoc_files: []
45
-
46
- files:
38
+ files:
47
39
  - ext/smb/smb.c
48
40
  - ext/smb/smb.cr
49
41
  - ext/smb/smb.rd
@@ -55,36 +47,29 @@ files:
55
47
  - ext/smb/extconf.rb
56
48
  homepage: http://github.com/geoffyoungs/smb-ruby
57
49
  licenses: []
58
-
59
50
  post_install_message:
60
51
  rdoc_options: []
61
-
62
- require_paths:
52
+ require_paths:
63
53
  - lib
64
- required_ruby_version: !ruby/object:Gem::Requirement
54
+ required_ruby_version: !ruby/object:Gem::Requirement
65
55
  none: false
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- hash: 3
70
- segments:
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ segments:
71
61
  - 0
72
- version: "0"
73
- required_rubygems_version: !ruby/object:Gem::Requirement
62
+ hash: -3014513220531350043
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
64
  none: false
75
- requirements:
76
- - - ">="
77
- - !ruby/object:Gem::Version
78
- hash: 3
79
- segments:
80
- - 0
81
- version: "0"
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
82
69
  requirements: []
83
-
84
70
  rubyforge_project:
85
- rubygems_version: 1.8.24
71
+ rubygems_version: 1.8.25
86
72
  signing_key:
87
73
  specification_version: 3
88
74
  summary: libsmbclient bindings for ruby
89
75
  test_files: []
90
-