2010-05-02 01:10:11 -04:00
|
|
|
require 'fog/model'
|
|
|
|
# require 'fog/local/models/files'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Local
|
|
|
|
|
|
|
|
class Directory < Fog::Model
|
2010-05-04 17:31:42 -04:00
|
|
|
extend Fog::Deprecation
|
|
|
|
deprecate(:name, :key)
|
|
|
|
deprecate(:name=, :key=)
|
2010-05-02 01:10:11 -04:00
|
|
|
|
2010-05-04 17:31:42 -04:00
|
|
|
identity :key
|
2010-05-02 01:10:11 -04:00
|
|
|
|
|
|
|
def destroy
|
2010-05-04 17:31:42 -04:00
|
|
|
requires :key
|
2010-05-02 01:10:11 -04:00
|
|
|
|
|
|
|
if ::File.directory?(path)
|
|
|
|
Dir.rmdir(path)
|
|
|
|
true
|
|
|
|
else
|
|
|
|
false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def files
|
|
|
|
@files ||= begin
|
|
|
|
Fog::Local::Files.new(
|
|
|
|
:directory => self,
|
|
|
|
:connection => connection
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
2010-05-04 17:31:42 -04:00
|
|
|
requires :key
|
2010-05-02 01:10:11 -04:00
|
|
|
|
|
|
|
Dir.mkdir(path)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def path
|
2010-05-04 17:31:42 -04:00
|
|
|
connection.path_to(key)
|
2010-05-02 01:10:11 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|