r9p

git clone git://oldgit.suckless.org/r9p/
Log | Files | Refs

test.rb (752B)


      1 #$debug = 5
      2 require 'r9p.rb'
      3 
      4 module R9P
      5 	include Client::Constants
      6 
      7 	Client.new('unix!/tmp/ns.kris.:1/wmii') { |c|
      8 		c.open('/') { |f|
      9 			f.readdir.each { |f| 
     10 				puts "/#{f.name}:"
     11 				f.fields.each_pair { |k, v|
     12 					puts "\t#{k.id2name}: #{v.inspect}"
     13 				}
     14 			}
     15 		}
     16 
     17 		c.open('/keys') { |f|
     18 			puts "\n/keys:"
     19 			print f.read
     20 		}
     21 
     22 		name = "Foo"
     23 		path = ["/rbar/foo", "/rbar/bar"]
     24 		if c.stat(path[0])
     25 			name = "Bar"
     26 			t = path.shift
     27 			path.push t
     28 		else
     29 			c.create(path[1]) {}
     30 		end
     31 		puts "Stat of #{path[1]}: #{c.stat path[1]}"
     32 		c.remove(path[1])
     33 		f = c.create(path[0], OWRITE) { |f|
     34 			f.write "#000000 #FFFFFF #000000 #{name}"
     35 		}
     36 
     37 		c.open('/ctl', OREAD) { |f|
     38 			f.to_fd { |fd|
     39 				print "From /ctl: #{fd.readline}"
     40 			}
     41 		}
     42 	}
     43 end