lib/rio/dir.rb in rio-0.3.7 vs lib/rio/dir.rb in rio-0.3.8

- old
+ new

@@ -1,8 +1,8 @@ #-- # =============================================================================== -# Copyright (c) 2005, Christopher Kleckner +# Copyright (c) 2005, 2006 Christopher Kleckner # All rights reserved # # This file is part of the Rio library for ruby. # # Rio is free software; you can redistribute it and/or modify @@ -20,11 +20,11 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # =============================================================================== #++ # # To create the documentation for Rio run the command -# rake rdoc +# ruby build_doc.rb # from the distribution directory. Then point your browser at the 'doc/rdoc' directory. # # Suggested Reading # * RIO::Doc::SYNOPSIS # * RIO::Doc::INTRO @@ -41,13 +41,10 @@ require 'rio/ioh' module RIO module Dir #:nodoc: all class Base < State::Base include Ops::Path::Str - def self.copy_(src,dst) - Impl::U.cp_r(src,dst) - end def open?() !ioh.nil? end end class NonExisting < Base include Ops::Dir::NonExisting @@ -58,25 +55,31 @@ class Existing < Base include Ops::Dir::Existing def check?() self.directory? end def when_missing(sym,*args) dopen() end + + protected + + def stream_rl_ + self.rl.dir_rl() + #RIO::Dir::RL.new(self.to_uri, {:fs => self.fs}) + end + + public + def dopen() - self.rl = RIO::Dir::RL.new(self.to_uri) + self.rl = self.stream_rl_ become 'Dir::Open' end end class Open < Base def check?() true end - def open(m=nil,*args) - open_(*args) - end + def open(m=nil,*args) open_(*args) end def open_(*args) unless open? - ios = self.rl.open(*args) - self.ioh = IOH::Dir.new(ios) -# self.ioh = self.rl.open() + self.ioh = self.rl.open() end self end def when_missing(sym,*args) nobj = open_.dstream() @@ -94,21 +97,17 @@ end end class Stream < Base include Ops::Dir::Stream def check?() open? end - def when_missing(sym,*args) - #p callstr('when_missing',sym,*args) - retryreset() - end + def when_missing(sym,*args) retryreset() end def base_state() 'Dir::Close' end - - def reset() - self.close.softreset() - end + def reset() self.close.softreset() end alias :copyclose :reset end class Close < Base + def reopen(*args) self.close_.softreset.open(*args) end + def close() #p callstr('close')+" mode='#{mode?}' ioh=#{self.ioh} open?=#{open?}" return self unless self.open? self.close_ cx['retrystate'] = nil