lib/rio/ops/file.rb in rio-0.4.2 vs lib/rio/ops/file.rb in rio-0.5.1

- old
+ new

@@ -1,8 +1,8 @@ #-- -# =============================================================================== -# Copyright (c) 2005,2006,2007,2008 Christopher Kleckner +# =========================================================================== +# Copyright (c) 2005-2012 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 @@ -16,29 +16,18 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Rio; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# =============================================================================== +# =========================================================================== #++ # -# To create the documentation for Rio run the command -# ruby build_doc.rb -# from the distribution directory. -# -# Suggested Reading -# * RIO::Doc::SYNOPSIS -# * RIO::Doc::INTRO -# * RIO::Doc::HOWTO -# * RIO::Doc::EXAMPLES -# * RIO::Rio -# -require 'rio/cp' -require 'rio/piper/cp' -require 'rio/ops/either' +#require 'rio/cp' +#require 'rio/piper/cp' +#require 'rio/ops/either' # module RIO # module Impl # module U # def self.copy(s,d) @@ -73,30 +62,44 @@ %w[stream_sel stream_nosel].any? { |k| cx.has_key?(k) } end def empty?() self.selective? ? self.to_a.empty? : self.size == 0 end - def rm(*args) + def delete(*args) rtn_reset { - fs.rm(self,*args) + fs.delete(self,*args) } end - alias :delete :rm + alias :rm :delete alias :unlink :delete - alias :delete! :rm + alias :delete! :delete def touch(*args) rtn_self { fs.touch(self.to_s,*args) } end - def truncate(sz=0) rtn_reset { fs.truncate(self.to_s,sz) } end + def truncate(sz=0) + rtn_reset { + sz = 0 if sz < 0 + fs.truncate(self.to_s,sz) + } + end def clear() truncate(0) end end module NonExisting include ExistOrNot include FileOrDir::NonExisting - def rm(*args) rtn_self { ; } end - alias delete rm + def delete(*args) rtn_self { ; } end + alias :rm :delete alias :unlink :delete - alias delete! rm - def touch(*args) rtn_reset { fs.touch(self,*args) } end + alias :delete! :delete + def touch(*args) + rtn_reset { + # fs.touch(self,*args) + ::File.open(self.to_s, 'a') { + ; + } + } + + end + def truncate(sz=0) self.touch.truncate(sz) end end end end end