Skip to content

Instantly share code, notes, and snippets.

@benschwarz
Created October 16, 2008 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benschwarz/17141 to your computer and use it in GitHub Desktop.
Save benschwarz/17141 to your computer and use it in GitHub Desktop.
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