Class: RXFHelperModule::FileX

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

Class Method Summary collapse

Class Method Details

.chdir(s) ⇒ Object



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

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

.chmod(num, s) ⇒ Object



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

def self.chmod(num, s) RXFHelper.chmod(num, s)     end

.cp(s, s2) ⇒ Object



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

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

.directory?(filename) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/rxfhelper.rb', line 34

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)


75
76
77
# File 'lib/rxfhelper.rb', line 75

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

.exists?(filename) ⇒ Boolean

Returns:

  • (Boolean)


53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/rxfhelper.rb', line 53

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



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/rxfhelper.rb', line 79

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



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

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

.mkdir(s) ⇒ Object



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

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

.mkdir_p(s) ⇒ Object



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

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

.mv(s, s2) ⇒ Object



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

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

.pwdObject



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

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

.read(x) ⇒ Object



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

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

.rm(s) ⇒ Object



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

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

.rm_r(s, force: false) ⇒ Object



115
116
117
# File 'lib/rxfhelper.rb', line 115

def self.rm_r(s, force: false)
  RXFHelper.rm_r(s, force: force)
end

.ru(s) ⇒ Object



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

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

.ru_r(s) ⇒ Object



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

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

.touch(s, mtime: Time.now) ⇒ Object



122
123
124
# File 'lib/rxfhelper.rb', line 122

def self.touch(s, mtime: Time.now)
  RXFHelper.touch(s, mtime: mtime)
end

.write(x, s) ⇒ Object



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

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

.zip(s, a) ⇒ Object



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

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