Class: FileSystem::FileUtilsAdapter

Inherits:
Object
  • Object
show all
Extended by:
Adapter
Defined in:
lib/filesystem.rb

Overview

:nodoc:

Class Method Summary collapse

Methods included from Adapter

get_node, method_missing, respond_to?

Class Method Details

.cp(src, dest, options = {}) ⇒ Object



164
165
166
167
168
169
170
171
# File 'lib/filesystem.rb', line 164

def self.cp( src, dest, options = {} )
	file = get_node( src ).clone
	dest_path = Path.new( dest ).absolute
	dest_dir = get_node( dest_path.parent )
	dest_dir[dest_path.node] = file
	file.name = dest_path.node
	file.parent = dest_dir
end

.mv(src, dest, options = {}) ⇒ Object



173
174
175
176
# File 'lib/filesystem.rb', line 173

def self.mv( src, dest, options = {} )
	cp( src, dest, options )
	FileSystem.get_file.delete( src )
end

.touch(file) ⇒ Object



178
179
180
181
182
183
184
185
186
187
# File 'lib/filesystem.rb', line 178

def self.touch( file )
	begin
		get_node( file ).mtime = Time.now
	rescue Errno::ENOENT
		path = Path.new( file ).absolute
		parent_dir = get_node( path.parent )
		file = MockFileSystem::MockFile.new( parent_dir, path.node, nil )
		parent_dir[path.node] = file
	end
end