Class: Gflocator::Handler

Inherits:
Object
  • Object
show all
Defined in:
lib/gflocator/handler.rb

Instance Method Summary collapse

Instance Method Details

#get_locations(args, glob_flag) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/gflocator/handler.rb', line 22

def get_locations args, glob_flag
  if glob_flag
    paths = Dir.glob args.join("\0")
  else
    paths = args
  end
  name = 'trusted.glusterfs.pathinfo'
  locations = {}
  for path in paths
    if (loc_str = xattr_get(path, name))
      res = loc_str.scan(/<POSIX(?:\([^\)]+\))?:([-\w\.]+):([^>]+)>/)
      locations[path] = res
    else
      raise RuntimeError, 'getxattr failed'
    end
  end
  locations
end

#xattr_get(path, name) ⇒ Object



13
14
15
# File 'lib/gflocator/handler.rb', line 13

def xattr_get path, name
  XAttr.get path, name
end