Module: RIO::Ops::FileOrDir::Existing

Includes:
ExistOrNot
Included in:
Dir::Existing, Dir::Stream, RIO::Ops::File::Existing
Defined in:
lib/rio/ops/either.rb

Instance Method Summary collapse

Instance Method Details

#basename=(arg) ⇒ Object



90
91
92
93
94
95
# File 'lib/rio/ops/either.rb', line 90

def basename=(arg)
  dst = ::Alt::URI.create(path: uri.path)
  dst.ext = cx['ext'] if cx.has_key?('ext')
  dst.basename = arg.to_s
  rename!(dst.path)
end

#chmod(mod) ⇒ Object



54
# File 'lib/rio/ops/either.rb', line 54

def chmod(mod) rtn_self { fs.chmod(mod,fspath) } end

#chown(owner, group) ⇒ Object



55
# File 'lib/rio/ops/either.rb', line 55

def chown(owner,group) rtn_self { fs.chown(owner,group,fspath) } end

#dirname=(arg) ⇒ Object



80
81
82
83
84
# File 'lib/rio/ops/either.rb', line 80

def dirname=(arg)
  dst = ::Alt::URI.create(path: uri.path)
  dst.dirname = arg.to_s
  rename!(dst.path)
end

#empty?Boolean

Returns:

  • (Boolean)


122
# File 'lib/rio/ops/either.rb', line 122

def empty?() self.to_a.empty? end

#extname=(arg) ⇒ Object



96
97
98
99
100
101
102
# File 'lib/rio/ops/either.rb', line 96

def extname=(arg)
  dst = ::Alt::URI.create(path: uri.path)
  dst.ext = cx['ext'] if cx.has_key?('ext')
  dst.extname = arg.to_s
  rename!(dst.path)
  cx['ext'] = arg
end

#filename=(arg) ⇒ Object



85
86
87
88
89
# File 'lib/rio/ops/either.rb', line 85

def filename=(arg)
  dst = ::Alt::URI.create(path: uri.path)
  dst.filename = arg.to_s
  rename!(dst.path)
end

#mountpoint?Boolean

Returns:

  • (Boolean)


119
120
121
# File 'lib/rio/ops/either.rb', line 119

def mountpoint?
  fs.mountpoint?(fspath)
end

#must_existObject



56
# File 'lib/rio/ops/either.rb', line 56

def must_exist() self end

#realpathObject



116
117
118
# File 'lib/rio/ops/either.rb', line 116

def realpath
  new_rio(fs.realpath(fspath))
end

#rename(*args, &block) ⇒ Object Also known as: mv



58
59
60
61
62
63
64
65
66
67
# File 'lib/rio/ops/either.rb', line 58

def rename(*args,&block)
  if args.empty?
    softreset.rename(*args,&block)
  else
    rtn_reset { 
      dst = args.shift.to_s
      fs.mv(uri.path,dst,*args) unless uri.path == dst
    } 
  end
end

#rename!(*args, &block) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
# File 'lib/rio/ops/either.rb', line 68

def rename!(*args,&block)
  if args.empty?
    softreset.rename(*args,&block)
  else
    rtn_reset { 
      cpath = uri.path
      uri.path = args.shift.to_s
      fs.mv(cpath,uri.path,*args) unless uri.path == cpath
    } 
  end
end

#ss_type?Boolean

Returns:

  • (Boolean)


104
105
106
107
108
109
110
111
112
113
# File 'lib/rio/ops/either.rb', line 104

def ss_type?
  case cx['ss_type']
  when nil
    'entries'
  when 'files', 'dirs', 'entries', 'skipfiles', 'skipdirs', 'skipentries'
    cx['ss_type'] 
  else
    nil
  end
end