qid.rb (699B)
1 # Copyright (C) 2007 Kris Maglione 2 # See PERMISSIONS 3 4 module R9P 5 class Qid <Serial 6 module Constants 7 QTFILE = 0x00 8 QTLINK = 0x01 9 QTSYMLINK = 0x02 10 QTTMP = 0x04 11 QTAUTH = 0x08 12 QTMOUNT = 0x10 13 QTEXCL = 0x20 14 QTAPPEND = 0x40 15 QTDIR = 0x80 16 end 17 include Constants 18 19 class Type <Serial 20 field :type, :byte 21 22 alias to_i type 23 24 def to_s 25 const = Qid.constants.grep(/^QT/) 26 const.collect! { |c| 27 v = Qid.const_get(c) 28 if type&v == v 29 c 30 end 31 } 32 const.reject! {|i| i == nil} 33 const.join '|' 34 end 35 end 36 37 field :type, Type 38 field :vers, :dword 39 field :path, :qword 40 41 def to_s 42 "type: #{type} vers: #{vers} path: #{path}" 43 end 44 end 45 end