2010-10-04 17:02:08 -04:00
|
|
|
require 'fog/core/model'
|
2011-08-24 15:03:25 -04:00
|
|
|
require 'fog/local/models/storage/files'
|
2010-09-08 15:50:38 -04:00
|
|
|
|
|
|
|
module Fog
|
2011-06-15 17:26:43 -04:00
|
|
|
module Storage
|
|
|
|
class Local
|
2010-09-08 15:50:38 -04:00
|
|
|
|
|
|
|
class Directory < Fog::Model
|
|
|
|
|
|
|
|
identity :key
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
requires :key
|
|
|
|
|
|
|
|
if ::File.directory?(path)
|
|
|
|
Dir.rmdir(path)
|
|
|
|
true
|
|
|
|
else
|
|
|
|
false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def files
|
|
|
|
@files ||= begin
|
2011-06-15 17:26:43 -04:00
|
|
|
Fog::Storage::Local::Files.new(
|
2010-09-08 15:50:38 -04:00
|
|
|
:directory => self,
|
2012-12-22 18:25:11 -05:00
|
|
|
:service => service
|
2010-09-08 15:50:38 -04:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-11-05 14:37:12 -04:00
|
|
|
def public=(new_public)
|
|
|
|
new_public
|
|
|
|
end
|
|
|
|
|
|
|
|
def public_url
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
2010-09-08 15:50:38 -04:00
|
|
|
def save
|
|
|
|
requires :key
|
|
|
|
|
2012-10-06 18:33:39 -04:00
|
|
|
FileUtils.mkpath(path)
|
2010-09-08 15:50:38 -04:00
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def path
|
2012-12-22 18:25:11 -05:00
|
|
|
service.path_to(key)
|
2010-09-08 15:50:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|