lib/rio/ext/zipfile/state.rb in rio-0.5.1 vs lib/rio/ext/zipfile/state.rb in rio-0.6.0

- old
+ new

@@ -1,8 +1,8 @@ #-- # =========================================================================== -# Copyright (c) 2005-2012 Christopher Kleckner +# Copyright (c) 2005-2017 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 @@ -36,115 +36,11 @@ if rl.to_s.empty? become('Dir::Open') else become('Path::Reset') end - #gofigure(sym,*args) end end end end end __END__ - class Base < State::Base - include Ops::Path::Str - def open?() !ioh.nil? end - end - - class NonExisting < Base - include Ops::Dir::NonExisting - def check?() not self.exist? end - def when_missing(sym,*args) gofigure(sym,*args) end - end - - 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 = 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_(*args) - unless open? - self.ioh = self.rl.open() - end - self - end - def when_missing(sym,*args) - nobj = open_.dstream() - return nobj unless nobj.nil? - gofigure(sym,*args) - end - - def dstream() - cl = 'Dir::Stream' - #p "LOOP: retry: #{cx['retrystate'].inspect} => #{cl}" - return nil if cx['retrystate'] == cl - cx['retrystate'] = cl - - become(cl) - end - end - class Stream < Base - include Ops::Dir::Stream - def check?() open? end - def when_missing(sym,*args) retryreset() end - def base_state() 'Dir::Close' 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 - self - end - - def close_() - #p callstr('close_')+" ioh=#{self.ioh} open?=#{open?}" - return self unless self.open? - self.clear_selection - self.ioh.close - self.ioh = nil - self.rl.close - self - end - protected :close_ - - CX_ENTRY_SEL_KEYS = %w[nostreamenum entry_sel skip_args ss_skipped] - def clear_selection() - CX_ENTRY_SEL_KEYS.each { |k| - cx.delete(k) - } - self - end - - def check?() true end - def when_missing(sym,*args) - # p callstr('when_missing',sym,*args) - self.close_.retryreset() - end - end - end - end - end -end # module RIO