Created
October 16, 2008 14:05
-
-
Save benschwarz/17141 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin | |
require 'minigems' | |
rescue LoadError | |
require 'rubygems' | |
end | |
require 'fusefs' | |
require 'flickr-rest' | |
require 'flickr-wrapper' | |
require 'openuri_memcached' | |
include FuseFS | |
OpenURI::Cache.enable! | |
if (ARGV.size != 2) | |
puts "Usage: #{$0} <user_id> [36821533@N00] <directory>" | |
exit | |
end | |
class FlickrFS < FuseFS::FuseDir | |
def initialize(user_id) | |
@photosets = Flickr::PhotoSet.list(user_id) | |
end | |
def directory?(path) | |
items = scan_path(path) | |
return (@photosets-items) ? true : false | |
end | |
def contents(path) | |
@photosets.collect{|p| p.title} | |
end | |
end | |
user_id, dirname = ARGV | |
if (! File.directory?(dirname)) | |
puts "#{dirname} is not a directory" | |
end | |
root = FlickrFS.new(user_id) | |
# Set the root FuseFS | |
FuseFS.set_root(root) | |
FuseFS.mount_under(dirname) | |
FuseFS.run # This doesn't return until we're unmounted. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment