Class: SMB::Dir

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/smb/vfs.rb,
ext/smb/smb.c

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeObject



611
612
613
614
615
616
617
618
619
# File 'ext/smb/smb.c', line 611

static VALUE
Dir_initialize(VALUE self)
{
rb_smbprivate *dir; Data_Get_Struct(self, rb_smbprivate, dir);

#line 171 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
  
  return Qnil;
}

Class Method Details

.entries(url) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/smb/vfs.rb', line 13

def self.entries(url)
	list = []
	d = SMB::Dir.new(url)
	begin
		while entry = d.read
			list << entry
		end
	ensure
		d.close
	end
	list
end

.foreach(url) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/smb/vfs.rb', line 25

def self.foreach(url)
	d = SMB::Dir.new(url)
	begin
		while entry = d.read
			yield(entry)
		end
	ensure
		d.close
	end
end

.mkdir(__v_url, __v_mode) ⇒ Object



597
598
599
600
601
602
603
604
605
606
607
608
609
# File 'ext/smb/smb.c', line 597

static VALUE
Dir_CLASS_mkdir(VALUE self, VALUE __v_url, VALUE __v_mode)
{
  char * url; char * __orig_url;
  int mode; int __orig_mode;
  __orig_url = url = ( NIL_P(__v_url) ? NULL : StringValuePtr(__v_url) );
  __orig_mode = mode = NUM2INT(__v_mode);

#line 164 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
  if (smbc_mkdir(url, mode) < 0) rb_sys_fail(url);
 
  return Qnil;
}

.new(__v_url) ⇒ Object



560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
# File 'ext/smb/smb.c', line 560

static VALUE
Dir_CLASS_new(VALUE self, VALUE __v_url)
{
  VALUE __p_retval = Qnil;
  char * url; char * __orig_url;
  __orig_url = url = ( NIL_P(__v_url) ? NULL : StringValuePtr(__v_url) );

#line 144 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"

  do {
  volatile VALUE  val  ;
 struct rb_smbprivate * dir  ;
 int  handle  ;
 if((handle = smbc_opendir(url)) < 0) { rb_sys_fail("Unable to open dir URL");
  } val = Data_Make_Struct(self, struct rb_smbprivate, 0, smbprivate_free, dir);
  dir->handle = handle;
  rb_obj_call_init(val, 0, NULL);
  do { __p_retval = val; goto out; } while(0);

  } while(0);

out:
  return __p_retval;
}

.rmdir(__v_url) ⇒ Object



585
586
587
588
589
590
591
592
593
594
595
# File 'ext/smb/smb.c', line 585

static VALUE
Dir_CLASS_rmdir(VALUE self, VALUE __v_url)
{
  char * url; char * __orig_url;
  __orig_url = url = ( NIL_P(__v_url) ? NULL : StringValuePtr(__v_url) );

#line 160 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
  if (smbc_rmdir(url) < 0) rb_sys_fail(url);
 
  return Qnil;
}

Instance Method Details

#closeObject



683
684
685
686
687
688
689
690
691
692
693
# File 'ext/smb/smb.c', line 683

static VALUE
Dir_close(VALUE self)
{
rb_smbprivate *dir; Data_Get_Struct(self, rb_smbprivate, dir);

#line 196 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
  smbc_closedir(dir->handle);
  dir->handle = 0;
 
  return Qnil;
}

#each(&block) ⇒ Object



8
9
10
11
12
# File 'lib/smb/vfs.rb', line 8

def each(&block)
	while entry = read()
		yield(entry)
	end
end

#readObject



640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
# File 'ext/smb/smb.c', line 640

static VALUE
Dir_read(VALUE self)
{
  VALUE __p_retval = Qnil;
rb_smbprivate *dir; Data_Get_Struct(self, rb_smbprivate, dir);

#line 184 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"

  do {
  struct smbc_dirent*  de  ;
 de = smbc_readdir(dir->handle);
  if(de) do { __p_retval =  rb_str_new2(de->name); goto out; } while(0);

  } while(0);

out:
  return __p_retval;
}

#read_entryObject



621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
# File 'ext/smb/smb.c', line 621

static VALUE
Dir_read_entry(VALUE self)
{
  VALUE __p_retval = Qnil;
rb_smbprivate *dir; Data_Get_Struct(self, rb_smbprivate, dir);

#line 173 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"

  do {
  struct smbc_dirent*  de  ;
 de = smbc_readdir(dir->handle);
  if(de) { do { __p_retval = rb_struct_new(structDirEntry,  INT2NUM(de->smbc_type),  rb_str_new2(de->comment),  rb_str_new2(de->name)); goto out; } while(0); }

  } while(0);

out:
  return __p_retval;
}

#tellObject



659
660
661
662
663
664
665
666
667
668
669
# File 'ext/smb/smb.c', line 659

static VALUE
Dir_tell(VALUE self)
{
  VALUE __p_retval = Qnil;
rb_smbprivate *dir; Data_Get_Struct(self, rb_smbprivate, dir);

#line 190 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
  do { __p_retval =  INT2NUM(smbc_telldir(dir->handle)); goto out; } while(0);
out:
  return __p_retval;
}

#urlObject



671
672
673
674
675
676
677
678
679
680
681
# File 'ext/smb/smb.c', line 671

static VALUE
Dir_url(VALUE self)
{
  VALUE __p_retval = Qnil;
rb_smbprivate *dir; Data_Get_Struct(self, rb_smbprivate, dir);

#line 193 "/home/geoff/Projects/smb-ruby/ext/smb/smb.cr"
  do { __p_retval =  rb_str_new2(dir->url); goto out; } while(0);
out:
  return __p_retval;
}