Class: RXFHelperModule::FileX

Inherits:
Object
  • Object
show all
Defined in:
lib/rxfhelper.rb

Class Method Summary collapse

Class Method Details

.chdir(s) ⇒ Object



19
# File 'lib/rxfhelper.rb', line 19

def self.chdir(s)  RXFHelper.chdir(s)   end

.cp(s, s2) ⇒ Object



92
# File 'lib/rxfhelper.rb', line 92

def self.cp(s, s2)    RXFHelper.cp(s, s2)      end

.directory?(filename) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rxfhelper.rb', line 21

def self.directory?(filename)
  
  type = self.filetype(filename)
  
  filex = case type
  when :file
    File
  when :dfs
    DfsFile
  else
    nil
  end

  return nil unless filex
  
  filex.directory? filename
  
end

.exist?(filename) ⇒ Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/rxfhelper.rb', line 62

def self.exist?(filename)
  exists? filename
end

.exists?(filename) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/rxfhelper.rb', line 40

def self.exists?(filename)
  
  type = self.filetype(filename)
  
  filex = case type
  when :file
    File
  when :dfs
    DfsFile
  when :sqlite
    host = filename[/(?<=^sqlite:\/\/)[^\/]+/]
    DRbObject.new nil, "druby://#{host}:57000"
  else
    nil
  end

  return nil unless filex
  
  filex.exists? filename
  
end

.filetype(x) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/rxfhelper.rb', line 66

def self.filetype(x)
  
  return :string if x.lines.length > 1
  
  case x
  when /^rse:\/\//
    :rse
  when /^https?:\/\//
    :http
  when /^dfs:\/\//
    :dfs
  when /^sqlite:\/\//
    :sqlite
  when /^file:\/\//
    :file
  else
    
    if File.exists?(x) then
      :file
    else
      :text
    end
    
  end
end

.ls(s) ⇒ Object



93
# File 'lib/rxfhelper.rb', line 93

def self.ls(s)        RXFHelper.ls(s)          end

.mkdir(s) ⇒ Object



94
# File 'lib/rxfhelper.rb', line 94

def self.mkdir(s)     RXFHelper.mkdir(s)       end

.mkdir_p(s) ⇒ Object



95
# File 'lib/rxfhelper.rb', line 95

def self.mkdir_p(s)   RXFHelper.mkdir_p(s)     end

.mv(s, s2) ⇒ Object



96
# File 'lib/rxfhelper.rb', line 96

def self.mv(s, s2)    RXFHelper.mv(s, s2)      end

.pwdObject



97
# File 'lib/rxfhelper.rb', line 97

def self.pwd()        RXFHelper.pwd()          end

.read(x) ⇒ Object



98
# File 'lib/rxfhelper.rb', line 98

def self.read(x)      RXFHelper.read(x).first  end

.rm(s) ⇒ Object



99
# File 'lib/rxfhelper.rb', line 99

def self.rm(s)        RXFHelper.rm(s)          end

.write(x, s) ⇒ Object



100
# File 'lib/rxfhelper.rb', line 100

def self.write(x, s)  RXFHelper.write(x, s)    end

.zip(s, a) ⇒ Object



101
# File 'lib/rxfhelper.rb', line 101

def self.zip(s, a)    RXFHelper.zip(s, a)    end