lib/rio/cp.rb in rio-0.3.7 vs lib/rio/cp.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 @@ -40,16 +40,38 @@ def clear() self[0..-1] = '' self end end +require 'rio/no_warn' + module RIO module Cp #:nodoc: all module Util module InOut def cpclose(*args,&block) if args.empty? + oldcoc = self.cx.get_keystate('closeoncopy') + self.cx['closeoncopy'] = false + rtn = yield + rtn.cx.set_keystate(*oldcoc) + rtn.copyclose + else + if (ario = args[0]).kind_of?(Rio) + oldcoc = ario.cx.get_keystate('closeoncopy') + ario.cx['closeoncopy'] = false + rtn = yield + ario.cx.set_keystate(*oldcoc) + ario.copyclose + rtn + else + yield + end + end + end + def cpclose0(*args,&block) + if args.empty? oldcoc,self.cx['closeoncopy'] = self.cx['closeoncopy'],false rtn = yield rtn.cx['closeoncopy'] = oldcoc rtn.copyclose else @@ -139,14 +161,16 @@ cpto_obj_(arg) end def cpto_rio_(arg,sym) ario = ensure_rio(arg) + #p ario ario = ario.join(self.filename) if ario.dir? ario.cpclose { ario = ario.iostate(sym) self.copying(ario).each { |el| +# p el ario.putrec(el) # ario << el }.copying_done(ario) ario } @@ -164,19 +188,20 @@ def cpfrom_(arg) case arg when ::Array then cpfrom_array_(arg) when ::IO then cpfrom_obj_(arg) - when ::String then self.put_(arg) + when ::String then + self.put_(arg) else cpfrom_rio_(arg) end self end def cpfrom_rio_(arg) ensure_rio(arg).copying(self).each { |el| - self.putrec(el) -# self << el + #self.putrec(el) + self << el }.copying_done(self) end end end end @@ -204,11 +229,12 @@ def copy_as_file?(arg) arg.kind_of?(Rio) and arg.scheme == 'ftp' end def spcp(arg) if arg.kind_of?(Rio) and arg.scheme == 'ftp' - arg < new_rio(rl.path) + arg.copy_from(new_rio(rl.path)) + #arg < new_rio(rl.path) self else nil end end @@ -253,11 +279,10 @@ when ::Array then cpfrom_array_(arg) else cpfrom_rio_(ensure_rio(arg)) end end def cpfrom_rio_(ario) - #p callstr('cpfrom_rio_',ario) dest = self.join(ario.filename) case when ario.symlink? ::File.symlink(ario.readlink.to_s,dest.to_s) when ario.dir? @@ -287,11 +312,11 @@ self end alias :copy_to :> alias :append_to :>> - private + protected def cpto_rio_(ario) ario = ario.join(self.filename) if ario.exist? nostreamenum.cpto_obj_(ario.mkdir) end @@ -304,10 +329,11 @@ module NonExisting module Output include Util::Output def <(arg) if _switch_direction?(arg) - arg > self + #arg > self + arg.copy_to(self) self else _cpsrc(arg) < arg end end