prcd-fs.rb 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. require 'rfusefs'
  2. require 'net/http'
  3. require 'open-uri'
  4. class PRCD
  5. def initialize()
  6. @prcd = { "cristo" => "cri",
  7. "gesu" => "ges",
  8. "madonna" => "mad",
  9. "dio" => "dio",
  10. "madre_teresa" => "mtc",
  11. "papa" => "pap",
  12. "varie" => "vsf"
  13. }
  14. @prcd.each do |key, value|
  15. url = "http://www.papuasia.org/prcd/prcd_"+value+".txt"
  16. puts url
  17. @prcd[key] = []
  18. open(url).each_line do |r|
  19. @prcd[key].push(r.chomp)
  20. end
  21. end
  22. end
  23. def contents(path)
  24. @prcd.keys.push("random")
  25. end
  26. def file?(path)
  27. file, o = scan_path(path)
  28. if !file.nil? && (@prcd.has_key?(file) || file == "random") && o == nil
  29. return true
  30. end
  31. return false
  32. end
  33. def size(path)
  34. 10000
  35. end
  36. def read_file(path)
  37. file, o = scan_path(path)
  38. if file == "random"
  39. @prcd[@prcd.keys.sample].sample
  40. else
  41. @prcd[file].sample
  42. end
  43. end
  44. end
  45. FuseFS.start(PRCD.new, ARGV.shift)