lib/rio/ops/dir.rb in rio-0.4.2 vs lib/rio/ops/dir.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/grande'
require 'rio/cp'
-require 'rio/ops/either'
+#require 'rio/ops/either'
module RIO
# module Impl
# module U
# def self.rmdir(s) ::Dir.rmdir(s.to_s) end
@@ -81,16 +70,18 @@
module Dir
module NonExisting
include ExistOrNot
include ::RIO::Ops::FileOrDir::NonExisting
def mkdir(*args)
- fs.mkdir(self.to_s,*args);
+ #p "ops/dir/mkdir: self=#{self.to_s}"
+ #p "ops/dir/mkdir: self.path=#{self.path.inspect}"
+ fs.mkdir(self.path,*args);
softreset()
end
def mkpath(*args)
# p callstr('mkpath',*args)
- fs.mkpath(self.to_s,*args);
+ fs.mkpath(self.path,*args);
#fs.mkpath(self,*args);
softreset()
end
def rmdir(*args) self end
def rmtree(*args) self end
@@ -125,15 +116,15 @@
end
def empty?() self.to_a.empty? end
def mkdir(*args) self end
def mkpath(*args) self end
def rmdir(*args)
- fs.rmdir(self.to_s,*args);
+ fs.rmdir(self.path,*args);
softreset()
end
- def rmtree(*args) fs.rmtree(self.to_s,*args); softreset() end
- def rm(*args) fs.rm(self.to_s,*args); softreset() end
+ def rmtree(*args) fs.rmtree(self.path,*args); softreset() end
+ # def rm(*args) fs.rm(self.path,*args); softreset() end
alias :delete :rmdir
alias :unlink :delete
alias :delete! :rmtree
@@ -237,22 +228,25 @@
ent.rl.urlpath = indir.to_s
ent.join!(oldpath)
ent.cx = self.cx.bequeath(ent.cx)
ent
else
- # KIT: should this be RL.fs2url(ent) ???
if indir
+
new_rio_cx(indir.rl,ent)
else
new_rio_cx(ent)
end
end
end
def handle_ent_(ent,indir,sel,&block)
begin
+ #p "ENT=#{ent.inspect}"
+ #p "FS=#{rl.fs.inspect}"
+ #p "FS.ENCODING=#{rl.fs.encoding}"
+ ent.force_encoding(rl.fs.encoding)
erio = ent_to_rio_(ent,indir)
- #p "handle_ent_1: #{erio.cx.inspect}"
if stream_iter?
# case for iterating files in a directory (e.g. rio('adir').lines)
_add_stream_iter_cx(erio).each(&block) if erio.file? and sel.match?(erio)
else
yield _add_iter_cx(erio) if sel.match?(erio)
@@ -262,20 +256,19 @@
if cx.has_key?('all') and erio.directory?
rsel = Match::Entry::SelectorClassic.new(cx['r_sel'],cx['r_nosel'])
_add_recurse_iter_cx(erio).each(&block) if rsel.match?(erio)
end
- rescue ::Errno::ENOENT, ::URI::InvalidURIError => ex
+ rescue ::Errno::ENOENT => ex
$stderr.puts(ex.message+". Skipping.")
end
end
def each_(*args,&block)
#p "#{callstr('each_',*args)} sel=#{cx['entry_sel'].inspect}"
handle_skipped()
sel = Match::Entry::Selector.new(cx['entry_sel'])
indir = (self.to_s == '.' ? nil : self)
self.ioh.each do |ent|
- #next if
handle_ent_(ent,indir,sel,&block) unless ent =~ /^\.(\.)?$/
end
closeoneof? ? self.close : self
end
def each_ent_(*args,&block)