Programowanie (Moje Projekty), Programowanie (PHP, Java...), System (GNU, BSD, Windows...), Systemy plików (NFS, ext3...)

GConfFS 0.0.1.90 - Prawie działa zapis

21 listopada, 2006 o 21:27:28 Dodaj komentarz Poziom: 0 Permalink

Wsparcie niby do zapisu jest, ale nie działa. Nie mam siły/czasu żeby to zdebugować. Na razie wypuszczam wersje 0.0.1.90. Mam nadzieje, że wersja 0.0.2 będzie ostateczna ;)

  1. require 'fusefs'
  2. require 'gconf2'
  3.  
  4. class String
  5.         def lines
  6.                 split("\n")
  7.         end
  8. end
  9.  
  10. class GConfFS
  11.         def initialize
  12.                 @client = GConf::Client.default
  13.         end
  14.         def directory? path
  15.                 @client.dir_exists? path
  16.         end
  17.         def contents path
  18.                 content = []
  19.                 @client.all_dirs(path).each do |dir|
  20.                         content << dir.split("/").last
  21.                 end
  22.                 @client.all_entries(path).each do |entry|
  23.                         content << entry.key.split("/").last
  24.                 end
  25.                 content
  26.         end
  27.         def can_mkdir? path
  28.                 true
  29.         end
  30.         def mkdir path
  31.                 @client.add_dir path
  32.         end
  33.         def can_rmdir? path
  34.                 directory?(path)
  35.         end
  36.         def rmdir path
  37.                 @client.remove_dir path
  38.         end
  39.         def file? path
  40.                 !@client.dir_exists? path
  41.         end
  42.         def read_file path
  43.                 entry = @client[path]
  44.                 if entry.class == Array
  45.                         str = ""
  46.                         entry.each do |line|
  47.                                 str << line << "\n"
  48.                         end
  49.                         return str
  50.                 else
  51.                         return @client[path].to_s
  52.                 end
  53.         end
  54.         def can_write? path
  55.                 true
  56.         end
  57.         def write_to path, body
  58.                 body = body.strip.lines
  59.                 if body.lenght = 0
  60.                         @clinet[path] = body[0]
  61.                 else
  62.                         @client[path] = body
  63.                 end
  64.         end
  65.         def can_delete? path
  66.                 file? path
  67.         end
  68.         def delete path
  69.                 @client.unset path
  70.         end
  71. end
  72.  
  73. gconfdir = GConfFS.new
  74. FuseFS.set_root(gconfdir)
  75. FuseFS.mount_under ARGV.shift
  76. FuseFS.run

Łatki nie zamieszczam, bo cały plik uległ przeobrażeniu

Komentarze do wpisu

Możesz śledzić odpowiedzi poprzez kanał RSS. Możesz dodać komentarz lub zostawić ślad (trackback) ze swojego bloga.

Jeszcze nie ma żadnych komentarzy. Twój może być pierwszy.

Dodaj komentarz

Textile Lite włączony ( szczegółowy opis znaczników ):