rio 0.3.7 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +1273 -1482
- data/README +2 -2
- data/Rakefile +5 -5
- data/VERSION +1 -1
- data/{RUNME.1st.rb → build_doc.rb} +4 -10
- data/doc/ANNOUNCE +33 -80
- data/doc/RELEASE_NOTES +31 -1
- data/doc/generators/template/html/rio.rb +3 -3
- data/lib/rio/abstract_method.rb +2 -2
- data/lib/rio/argv.rb +2 -2
- data/lib/rio/arycopy.rb +2 -2
- data/lib/rio/assert.rb +2 -2
- data/lib/rio/base.rb +2 -2
- data/lib/rio/callstr.rb +47 -0
- data/lib/rio/const.rb +52 -0
- data/lib/rio/construct.rb +6 -24
- data/lib/rio/constructor.rb +12 -2
- data/lib/rio/context/autoclose.rb +73 -0
- data/lib/rio/context/copying.rb +2 -2
- data/lib/rio/context/cxx.rb +2 -2
- data/lib/rio/context/dir.rb +2 -2
- data/lib/rio/context/gzip.rb +2 -2
- data/lib/rio/context/methods.rb +6 -34
- data/lib/rio/context/skip.rb +2 -2
- data/lib/rio/context/stream.rb +2 -2
- data/lib/rio/context.rb +17 -2
- data/lib/rio/cp.rb +35 -9
- data/lib/rio/def.rb +54 -0
- data/lib/rio/dir.rb +19 -20
- data/lib/rio/doc/HOWTO.rb +23 -7
- data/lib/rio/doc/INTRO.rb +57 -23
- data/lib/rio/doc/MISC.rb +2 -2
- data/lib/rio/doc/OPTIONAL.rb +134 -0
- data/lib/rio/doc/SYNOPSIS.rb +11 -4
- data/lib/rio/doc.rb +2 -2
- data/lib/rio/entrysel.rb +25 -6
- data/lib/rio/exception/copy.rb +2 -2
- data/lib/rio/exception/notsupported.rb +47 -0
- data/lib/rio/exception/open.rb +2 -2
- data/lib/rio/exception/state.rb +2 -2
- data/lib/rio/exception.rb +2 -2
- data/lib/rio/ext/csv.rb +56 -11
- data/lib/rio/ext/yaml.rb +2 -2
- data/lib/rio/ext/zipfile.rb +91 -0
- data/lib/rio/ext.rb +38 -3
- data/lib/rio/factory.rb +17 -34
- data/lib/rio/file.rb +48 -8
- data/lib/rio/filter/closeoneof.rb +36 -16
- data/lib/rio/filter/gzip.rb +2 -2
- data/lib/rio/filter.rb +2 -2
- data/lib/rio/fs/base.rb +42 -0
- data/lib/rio/fs/impl.rb +123 -0
- data/lib/rio/fs/native.rb +76 -0
- data/lib/rio/{record.rb → fs/stream.rb} +21 -18
- data/lib/rio/fs/url.rb +64 -0
- data/lib/rio/ftp/{ioh.rb → conncache.rb} +38 -39
- data/lib/rio/ftp/dir.rb +95 -0
- data/lib/rio/ftp/fs.rb +173 -0
- data/lib/rio/ftp/ftpfile.rb +20 -0
- data/lib/rio/grande.rb +2 -2
- data/lib/rio/handle.rb +2 -2
- data/lib/rio/if/basic.rb +2 -2
- data/lib/rio/if/csv.rb +2 -2
- data/lib/rio/if/dir.rb +2 -2
- data/lib/rio/if/file.rb +26 -2
- data/lib/rio/if/fileordir.rb +44 -49
- data/lib/rio/if/grande.rb +32 -10
- data/lib/rio/if/grande_entry.rb +12 -2
- data/lib/rio/if/grande_stream.rb +17 -28
- data/lib/rio/if/internal.rb +2 -2
- data/lib/rio/if/path.rb +7 -6
- data/lib/rio/if/stream.rb +85 -29
- data/lib/rio/if/string.rb +2 -2
- data/lib/rio/if/temp.rb +2 -2
- data/lib/rio/if/test.rb +37 -4
- data/lib/rio/if/yaml.rb +2 -2
- data/lib/rio/if.rb +2 -2
- data/lib/rio/impl/path.rb +2 -2
- data/lib/rio/ioh.rb +17 -6
- data/lib/rio/iomode.rb +4 -3
- data/lib/rio/ios/fail.rb +107 -0
- data/lib/rio/ios/generic.rb +120 -0
- data/lib/rio/ios/mode.rb +61 -0
- data/lib/rio/ios/null.rb +120 -0
- data/lib/rio/iowrap.rb +129 -0
- data/lib/rio/kernel.rb +12 -3
- data/lib/rio/local.rb +2 -2
- data/lib/rio/match.rb +3 -3
- data/lib/rio/matchrecord.rb +2 -2
- data/lib/rio/no_warn.rb +50 -0
- data/lib/rio/{arrayio.rb → nullio.rb} +47 -86
- data/lib/rio/open3.rb +2 -2
- data/lib/rio/ops/construct.rb +20 -13
- data/lib/rio/ops/create.rb +10 -19
- data/lib/rio/ops/dir.rb +60 -54
- data/lib/rio/ops/either.rb +11 -9
- data/lib/rio/ops/file.rb +28 -24
- data/lib/rio/ops/path.rb +45 -43
- data/lib/rio/ops/stream/input.rb +12 -8
- data/lib/rio/ops/stream/output.rb +2 -2
- data/lib/rio/ops/stream/read.rb +35 -32
- data/lib/rio/ops/stream/write.rb +5 -5
- data/lib/rio/ops/stream.rb +7 -3
- data/lib/rio/ops/symlink.rb +12 -10
- data/lib/rio/path/reset.rb +5 -5
- data/lib/rio/path.rb +32 -24
- data/lib/rio/piper/cp.rb +2 -2
- data/lib/rio/piper.rb +2 -2
- data/lib/rio/prompt.rb +2 -2
- data/lib/rio/rectype.rb +9 -7
- data/lib/rio/rl/base.rb +5 -4
- data/lib/rio/rl/builder.rb +17 -5
- data/lib/rio/rl/ioi.rb +14 -4
- data/lib/rio/rl/path.rb +23 -15
- data/lib/rio/rl/pathmethods.rb +12 -2
- data/lib/rio/rl/uri.rb +13 -6
- data/lib/rio/scheme/aryio.rb +3 -3
- data/lib/rio/scheme/cmdio.rb +4 -3
- data/lib/rio/scheme/cmdpipe.rb +3 -35
- data/lib/rio/scheme/fd.rb +4 -3
- data/lib/rio/scheme/ftp.rb +36 -7
- data/lib/rio/scheme/http.rb +2 -2
- data/lib/rio/{context/closeoneof.rb → scheme/null.rb} +17 -11
- data/lib/rio/scheme/path.rb +28 -30
- data/lib/rio/scheme/stderr.rb +4 -4
- data/lib/rio/scheme/stdio.rb +6 -5
- data/lib/rio/scheme/strio.rb +10 -20
- data/lib/rio/scheme/sysio.rb +5 -2
- data/lib/rio/scheme/tcp.rb +4 -3
- data/lib/rio/scheme/temp.rb +14 -1
- data/lib/rio/state/error.rb +2 -2
- data/lib/rio/state.rb +80 -34
- data/lib/rio/stream/base.rb +7 -2
- data/lib/rio/stream/duplex.rb +13 -10
- data/lib/rio/stream/open.rb +74 -79
- data/lib/rio/stream.rb +15 -23
- data/lib/rio/symantics.rb +2 -2
- data/lib/rio/tempdir.rb +132 -132
- data/lib/rio/to_rio/all.rb +40 -0
- data/lib/rio/to_rio/array.rb +40 -0
- data/lib/rio/to_rio/io.rb +41 -0
- data/lib/rio/to_rio/object.rb +43 -0
- data/lib/rio/to_rio/string.rb +41 -0
- data/lib/rio/to_rio.rb +13 -2
- data/lib/rio/uri/file.rb +2 -2
- data/lib/rio/util.rb +2 -2
- data/lib/rio/version.rb +3 -3
- data/lib/rio.rb +16 -25
- data/test/bin/count_lines.rb +11 -0
- data/test/bin/find_lines.rb +13 -0
- data/test/bin/list_dir.rb +14 -0
- data/test/ftp/all.rb +9 -0
- data/test/ftp/anon_misc.rb +112 -0
- data/test/ftp/anon_read.rb +105 -0
- data/test/ftp/anon_special.rb +68 -0
- data/test/ftp/anon_write.rb +63 -0
- data/test/ftp/ftp2ftp.rb +51 -0
- data/test/ftp/initftpfiles.rb +14 -0
- data/test/ftp/testdef.rb +51 -0
- data/test/gem_runtests.rb +15 -15
- data/test/runalltests.rb +15 -0
- data/test/runftptests.rb +14 -0
- data/test/{1.rb → runhttptests.rb} +14 -14
- data/test/runtests.rb +14 -14
- data/test/tc/all.rb +36 -21
- data/test/tc/cmdpipe.rb +18 -15
- data/test/tc/copy-from-http.rb +89 -0
- data/test/tc/copy-from.rb +1 -52
- data/test/tc/copy.rb +19 -17
- data/test/tc/csv2.rb +6 -3
- data/test/tc/empty.rb +47 -0
- data/test/tc/emptyriodir.rb +129 -0
- data/test/tc/entsel.rb +110 -0
- data/test/tc/files_select.rb +92 -0
- data/test/tc/get.rb +7 -6
- data/test/tc/getrec.rb +2 -5
- data/test/tc/gzip.rb +82 -0
- data/test/tc/io_each_byte.rb +60 -0
- data/test/tc/io_read.rb +80 -0
- data/test/tc/iometh.rb +149 -0
- data/test/tc/likeio.rb +112 -0
- data/test/tc/methods.rb +10 -9
- data/test/tc/misc.rb +1 -37
- data/test/tc/null.rb +45 -0
- data/test/tc/pid.rb +31 -0
- data/test/tc/piper.rb +34 -37
- data/test/tc/programs_util.rb +24 -0
- data/test/tc/readline.rb +30 -0
- data/test/tc/rename.rb +12 -0
- data/test/tc/tempfile.rb +14 -0
- data/test/tc/testcase.rb +6 -0
- data/test/tc/tonl.rb +37 -0
- metadata +181 -144
- data/ex/colx.rb +0 -8
- data/ex/findinruby +0 -16
- data/ex/findruby +0 -15
- data/ex/passwd_report.rb +0 -8
- data/ex/prompt.rb +0 -25
- data/ex/rgb.txt.gz +0 -0
- data/ex/riocat +0 -35
- data/ex/riogunzip +0 -31
- data/ex/riogzip +0 -24
- data/ex/rioprompt.rb +0 -6
- data/ex/targz2zip +0 -17
- data/ex/tolf +0 -11
- data/lib/rio/ftp/conn.rb +0 -167
- data/lib/rio/ftp.rb +0 -275
- data/test/once.rb +0 -7
data/lib/rio/ops/construct.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# ===============================================================================
|
3
|
-
# Copyright (c) 2005, Christopher Kleckner
|
3
|
+
# Copyright (c) 2005, 2006 Christopher Kleckner
|
4
4
|
# All rights reserved
|
5
5
|
#
|
6
6
|
# This file is part of the Rio library for ruby.
|
@@ -22,7 +22,7 @@
|
|
22
22
|
#++
|
23
23
|
#
|
24
24
|
# To create the documentation for Rio run the command
|
25
|
-
#
|
25
|
+
# ruby build_doc.rb
|
26
26
|
# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
|
27
27
|
#
|
28
28
|
# Suggested Reading
|
@@ -34,21 +34,28 @@
|
|
34
34
|
# <b>Rio is pre-alpha software.
|
35
35
|
# The documented interface and behavior is subject to change without notice.</b>
|
36
36
|
|
37
|
+
module RIO
|
38
|
+
CONSTRUCTOR_SYMS = [
|
39
|
+
:strio,
|
40
|
+
:stdio,
|
41
|
+
:stderr,
|
42
|
+
:temp,
|
43
|
+
:tempfile,
|
44
|
+
:tempdir,
|
45
|
+
:tcp,
|
46
|
+
:cmdio,
|
47
|
+
:cmdpipe,
|
48
|
+
:sysio,
|
49
|
+
:fd,
|
50
|
+
]
|
51
|
+
end
|
37
52
|
|
38
53
|
module RIO
|
39
54
|
module Ops
|
40
55
|
module Construct
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
def temp(*args,&block) Rio.rio(:temp,*args,&block) end
|
45
|
-
def tempfile(*args,&block) Rio.rio(:tempfile,*args,&block) end
|
46
|
-
def tempdir(*args,&block) Rio.rio(:tempdir,*args,&block) end
|
47
|
-
def tcp(*args,&block) Rio.rio(:tcp,*args,&block) end
|
48
|
-
def cmdio(*args,&block) Rio.rio(:cmdio,*args,&block) end
|
49
|
-
def cmdpipe(*args,&block) Rio.rio(:cmdpipe,*args,&block) end
|
50
|
-
def sysio(*args,&block) Rio.rio(:sysio,*args,&block) end
|
51
|
-
def fd(*args,&block) Rio.rio(:fd,*args,&block) end
|
56
|
+
RIO::CONSTRUCTOR_SYMS.each { |sym|
|
57
|
+
module_eval "def #{sym}(*args,&block) Rio.rio(:#{sym},*args,&block) end"
|
58
|
+
}
|
52
59
|
end
|
53
60
|
end
|
54
61
|
end
|
data/lib/rio/ops/create.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# ===============================================================================
|
3
|
-
# Copyright (c) 2005, Christopher Kleckner
|
3
|
+
# Copyright (c) 2005, 2006 Christopher Kleckner
|
4
4
|
# All rights reserved
|
5
5
|
#
|
6
6
|
# This file is part of the Rio library for ruby.
|
@@ -22,7 +22,7 @@
|
|
22
22
|
#++
|
23
23
|
#
|
24
24
|
# To create the documentation for Rio run the command
|
25
|
-
#
|
25
|
+
# ruby build_doc.rb
|
26
26
|
# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
|
27
27
|
#
|
28
28
|
# Suggested Reading
|
@@ -36,23 +36,11 @@
|
|
36
36
|
|
37
37
|
|
38
38
|
module RIO
|
39
|
-
module Impl
|
40
|
-
module U
|
41
|
-
def self.getwd() ::Dir.getwd() end
|
42
|
-
def self.rootdir()
|
43
|
-
require 'rio/local'
|
44
|
-
::RIO::Local::ROOT_DIR
|
45
|
-
end
|
46
|
-
def self.join(*args)
|
47
|
-
::File.join(*args)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
39
|
module Ops
|
52
40
|
module Path
|
53
41
|
module Create
|
54
42
|
def join(*args)
|
55
|
-
new_rio(self,*args)
|
43
|
+
new_rio(self.rl,*args)
|
56
44
|
end
|
57
45
|
#alias :catpath :join
|
58
46
|
def join!(*args)
|
@@ -65,15 +53,18 @@ module RIO
|
|
65
53
|
end
|
66
54
|
|
67
55
|
def getwd(*args,&block)
|
68
|
-
new_rio(
|
56
|
+
new_rio(fs.getwd,*args,&block)
|
57
|
+
end
|
58
|
+
def cwd(*args,&block)
|
59
|
+
new_rio(fs.cwd,*args,&block)
|
69
60
|
end
|
70
|
-
|
61
|
+
|
71
62
|
def rootpath(*args,&block)
|
72
|
-
new_rio(
|
63
|
+
new_rio(fs.root(),*args,&block)
|
73
64
|
end
|
74
65
|
alias :root :rootpath
|
75
66
|
def cleanpath(*args)
|
76
|
-
new_rio(
|
67
|
+
new_rio(fs.cleanpath(fspath,*args))
|
77
68
|
end
|
78
69
|
end
|
79
70
|
end
|
data/lib/rio/ops/dir.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# ===============================================================================
|
3
|
-
# Copyright (c) 2005, Christopher Kleckner
|
3
|
+
# Copyright (c) 2005, 2006 Christopher Kleckner
|
4
4
|
# All rights reserved
|
5
5
|
#
|
6
6
|
# This file is part of the Rio library for ruby.
|
@@ -22,7 +22,7 @@
|
|
22
22
|
#++
|
23
23
|
#
|
24
24
|
# To create the documentation for Rio run the command
|
25
|
-
#
|
25
|
+
# ruby build_doc.rb
|
26
26
|
# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
|
27
27
|
#
|
28
28
|
# Suggested Reading
|
@@ -40,41 +40,41 @@ require 'rio/cp'
|
|
40
40
|
require 'rio/ops/either'
|
41
41
|
|
42
42
|
module RIO
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
43
|
+
# module Impl
|
44
|
+
# module U
|
45
|
+
# def self.rmdir(s) ::Dir.rmdir(s.to_s) end
|
46
|
+
# def self.mkdir(s,*args) ::Dir.mkdir(s.to_s,*args) end
|
47
|
+
# def self.chdir(s,&block) ::Dir.chdir(s.to_s,&block) end
|
48
|
+
# def self.foreach(s,&block) ::Dir.foreach(s.to_s,&block) end
|
49
|
+
# def self.entries(s) ::Dir.entries(s.to_s) end
|
50
|
+
# def self.cp_r(s,d)
|
51
|
+
# require 'fileutils'
|
52
|
+
# ::FileUtils.cp_r(s.to_s,d.to_s)
|
53
|
+
# end
|
54
|
+
# def self.find(s,&block)
|
55
|
+
# require 'find'
|
56
|
+
# Find.find(s.to_s) do |f|
|
57
|
+
# yield f
|
58
|
+
# end
|
59
|
+
# end
|
60
|
+
# def self.glob(gstr,*args,&block)
|
61
|
+
# ::Dir.glob(gstr,*args,&block)
|
62
|
+
# end
|
63
|
+
# def self.rmtree(s)
|
64
|
+
# require 'fileutils'
|
65
|
+
# ::FileUtils.rmtree(s.to_s)
|
66
|
+
# end
|
67
|
+
# def self.mkpath(s)
|
68
|
+
# require 'fileutils'
|
69
|
+
# ::FileUtils.mkpath(s.to_s)
|
70
|
+
# end
|
71
|
+
# end
|
72
|
+
# end
|
73
73
|
|
74
74
|
module Ops
|
75
75
|
module Dir
|
76
76
|
module ExistOrNot
|
77
|
-
include
|
77
|
+
include RIO::Ops::FileOrDir::ExistOrNot
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
@@ -84,13 +84,13 @@ module RIO
|
|
84
84
|
include ExistOrNot
|
85
85
|
include ::RIO::Ops::FileOrDir::NonExisting
|
86
86
|
def mkdir(*args)
|
87
|
-
|
88
|
-
Impl::U.mkdir(self,*args);
|
87
|
+
fs.mkdir(self.to_s,*args);
|
89
88
|
softreset()
|
90
89
|
end
|
91
90
|
def mkpath(*args)
|
92
91
|
# p callstr('mkpath',*args)
|
93
|
-
|
92
|
+
fs.mkpath(self.to_s,*args);
|
93
|
+
#fs.mkpath(self,*args);
|
94
94
|
softreset()
|
95
95
|
end
|
96
96
|
def rmdir(*args) self end
|
@@ -124,13 +124,14 @@ module RIO
|
|
124
124
|
def selective?
|
125
125
|
%w[entry_sel stream_sel stream_nosel].any? { |k| cx.has_key?(k) }
|
126
126
|
end
|
127
|
+
def empty?() self.to_a.empty? end
|
127
128
|
def mkdir(*args) self end
|
128
129
|
def mkpath(*args) self end
|
129
130
|
def rmdir(*args)
|
130
|
-
|
131
|
+
fs.rmdir(self.to_s,*args);
|
131
132
|
softreset()
|
132
133
|
end
|
133
|
-
def rmtree(*args)
|
134
|
+
def rmtree(*args) fs.rmtree(self.to_s,*args); softreset() end
|
134
135
|
|
135
136
|
alias :delete :rmdir
|
136
137
|
alias :delete! :rmtree
|
@@ -138,16 +139,16 @@ module RIO
|
|
138
139
|
|
139
140
|
def chdir(*args,&block)
|
140
141
|
if block_given?
|
141
|
-
|
142
|
+
fs.chdir(self.to_s,*args) { |dir|
|
142
143
|
yield new_rio('.')
|
143
144
|
}
|
144
145
|
else
|
145
|
-
|
146
|
+
fs.chdir(self.path,*args)
|
146
147
|
return new_rio('.')
|
147
148
|
end
|
148
149
|
self
|
149
150
|
end
|
150
|
-
|
151
|
+
|
151
152
|
def ensure_rio_cx(arg0)
|
152
153
|
return arg0 if arg0.kind_of?(::RIO::Rio)
|
153
154
|
new_rio_cx(arg0)
|
@@ -156,11 +157,11 @@ module RIO
|
|
156
157
|
def glob(*args,&block)
|
157
158
|
chdir do
|
158
159
|
if block_given?
|
159
|
-
|
160
|
+
fs.glob(*args) do |ent|
|
160
161
|
yield new_rio_cx(self,ent)
|
161
162
|
end
|
162
163
|
else
|
163
|
-
return
|
164
|
+
return fs.glob(*args).map { |ent| new_rio_cx(self,ent) }
|
164
165
|
end
|
165
166
|
end
|
166
167
|
end
|
@@ -181,7 +182,6 @@ module RIO
|
|
181
182
|
def entries(*args,&block) _set_select('entries',*args,&block) end
|
182
183
|
|
183
184
|
def each(*args,&block)
|
184
|
-
# p callstr('each',*args)
|
185
185
|
each_(*args,&block)
|
186
186
|
end
|
187
187
|
|
@@ -230,10 +230,16 @@ module RIO
|
|
230
230
|
args = cx['skip_args'] || []
|
231
231
|
self.skipentries(*args)
|
232
232
|
end
|
233
|
-
def
|
233
|
+
def ent_to_rio_(ent,indir)
|
234
|
+
if indir
|
235
|
+
new_rio_cx(indir.rl,ent)
|
236
|
+
else
|
237
|
+
new_rio_cx(ent)
|
238
|
+
end
|
239
|
+
end
|
240
|
+
def handle_ent_(ent,indir,sel,&block)
|
234
241
|
begin
|
235
|
-
erio =
|
236
|
-
|
242
|
+
erio = ent_to_rio_(ent,indir)
|
237
243
|
if stream_iter?
|
238
244
|
_add_stream_iter_cx(erio).each(&block) if erio.file? and sel.match?(erio)
|
239
245
|
else
|
@@ -253,10 +259,10 @@ module RIO
|
|
253
259
|
#p "#{callstr('each_',*args)} sel=#{cx['sel'].inspect} nosel=#{cx['nosel'].inspect}"
|
254
260
|
handle_skipped()
|
255
261
|
sel = Match::Entry::Selector.new(cx['entry_sel'])
|
256
|
-
|
257
|
-
self.ioh.each do |
|
258
|
-
next if
|
259
|
-
handle_ent_(
|
262
|
+
indir = (self.to_s == '.' ? nil : self)
|
263
|
+
self.ioh.each do |ent|
|
264
|
+
#next if
|
265
|
+
handle_ent_(ent,indir,sel,&block) unless ent =~ /^\.(\.)?$/
|
260
266
|
end
|
261
267
|
closeoneof? ? self.close : self
|
262
268
|
end
|
@@ -264,9 +270,9 @@ module RIO
|
|
264
270
|
#p "#{callstr('each_',*args)} sel=#{cx['sel'].inspect} nosel=#{cx['nosel'].inspect}"
|
265
271
|
handle_skipped()
|
266
272
|
sel = Match::Entry::Selector.new(cx['entry_sel'])
|
267
|
-
|
268
|
-
while
|
269
|
-
handle_ent_(
|
273
|
+
indir = (self.to_s == '.' ? nil : self)
|
274
|
+
while ent = self.ioh.read
|
275
|
+
handle_ent_(ent,indir,sel,&block) unless ent =~ /^\.(\.)?$/
|
270
276
|
end
|
271
277
|
closeoneof? ? self.close : self
|
272
278
|
end
|
data/lib/rio/ops/either.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# ===============================================================================
|
3
|
-
# Copyright (c) 2005, Christopher Kleckner
|
3
|
+
# Copyright (c) 2005, 2006 Christopher Kleckner
|
4
4
|
# All rights reserved
|
5
5
|
#
|
6
6
|
# This file is part of the Rio library for ruby.
|
@@ -22,7 +22,7 @@
|
|
22
22
|
#++
|
23
23
|
#
|
24
24
|
# To create the documentation for Rio run the command
|
25
|
-
#
|
25
|
+
# ruby build_doc.rb
|
26
26
|
# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
|
27
27
|
#
|
28
28
|
# Suggested Reading
|
@@ -57,13 +57,14 @@ module RIO
|
|
57
57
|
end
|
58
58
|
module NonExisting
|
59
59
|
include ExistOrNot
|
60
|
+
def empty?() false end
|
60
61
|
end
|
61
62
|
|
62
63
|
module Existing
|
63
64
|
include ExistOrNot
|
64
65
|
|
65
|
-
def chmod(mod) rtn_self {
|
66
|
-
def chown(owner,group) rtn_self {
|
66
|
+
def chmod(mod) rtn_self { fs.chmod(mod,fspath) } end
|
67
|
+
def chown(owner,group) rtn_self { fs.chown(owner,group,fspath) } end
|
67
68
|
def must_exist() self end
|
68
69
|
|
69
70
|
def rename(*args,&block)
|
@@ -72,7 +73,7 @@ module RIO
|
|
72
73
|
else
|
73
74
|
rtn_reset {
|
74
75
|
dst = ensure_rio(args.shift)
|
75
|
-
|
76
|
+
fs.mv(self,dst,*args)
|
76
77
|
dst.reset
|
77
78
|
}
|
78
79
|
end
|
@@ -83,7 +84,7 @@ module RIO
|
|
83
84
|
else
|
84
85
|
rtn_reset {
|
85
86
|
dst = ensure_rio(args.shift)
|
86
|
-
|
87
|
+
fs.mv(self,dst,*args)
|
87
88
|
dst.reset
|
88
89
|
self.rl = dst.rl.clone
|
89
90
|
}
|
@@ -117,12 +118,13 @@ module RIO
|
|
117
118
|
|
118
119
|
require 'pathname'
|
119
120
|
def realpath
|
120
|
-
new_rio(
|
121
|
+
new_rio(fs.realpath(fspath))
|
121
122
|
end
|
122
123
|
def mountpoint?
|
123
|
-
|
124
|
+
fs.mountpoint?(fspath)
|
124
125
|
end
|
125
|
-
|
126
|
+
def empty?() self.to_a.empty? end
|
127
|
+
|
126
128
|
end
|
127
129
|
|
128
130
|
end
|
data/lib/rio/ops/file.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# ===============================================================================
|
3
|
-
# Copyright (c) 2005, Christopher Kleckner
|
3
|
+
# Copyright (c) 2005, 2006 Christopher Kleckner
|
4
4
|
# All rights reserved
|
5
5
|
#
|
6
6
|
# This file is part of the Rio library for ruby.
|
@@ -22,7 +22,7 @@
|
|
22
22
|
#++
|
23
23
|
#
|
24
24
|
# To create the documentation for Rio run the command
|
25
|
-
#
|
25
|
+
# ruby build_doc.rb
|
26
26
|
# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
|
27
27
|
#
|
28
28
|
# Suggested Reading
|
@@ -39,24 +39,24 @@ require 'rio/cp'
|
|
39
39
|
require 'rio/piper/cp'
|
40
40
|
require 'rio/ops/either'
|
41
41
|
|
42
|
-
module RIO
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
end
|
42
|
+
# module RIO
|
43
|
+
# module Impl
|
44
|
+
# module U
|
45
|
+
# def self.copy(s,d)
|
46
|
+
# require 'fileutils'
|
47
|
+
# ::FileUtils.cp(s.to_s,d.to_s)
|
48
|
+
# end
|
49
|
+
# def self.rm(s)
|
50
|
+
# require 'fileutils'
|
51
|
+
# ::FileUtils.rm(s.to_s)
|
52
|
+
# end
|
53
|
+
# def self.touch(s)
|
54
|
+
# require 'fileutils'
|
55
|
+
# ::FileUtils.touch(s.to_s)
|
56
|
+
# end
|
57
|
+
# end
|
58
|
+
# end
|
59
|
+
# end
|
60
60
|
module RIO
|
61
61
|
module Ops
|
62
62
|
module File
|
@@ -73,15 +73,19 @@ module RIO
|
|
73
73
|
def selective?
|
74
74
|
%w[stream_sel stream_nosel].any? { |k| cx.has_key?(k) }
|
75
75
|
end
|
76
|
+
def empty?()
|
77
|
+
self.selective? ? self.to_a.empty? : self.size == 0
|
78
|
+
end
|
76
79
|
def rm(*args)
|
77
80
|
rtn_reset {
|
78
|
-
|
81
|
+
fs.rm(self,*args)
|
79
82
|
}
|
80
83
|
end
|
81
84
|
alias :delete :rm
|
82
85
|
alias :delete! :rm
|
83
|
-
|
84
|
-
def
|
86
|
+
def touch(*args) rtn_self { fs.touch(self.to_s,*args) } end
|
87
|
+
def truncate(sz=0) rtn_reset { fs.truncate(self.to_s,sz) } end
|
88
|
+
def clear() truncate(0) end
|
85
89
|
end
|
86
90
|
module NonExisting
|
87
91
|
include ExistOrNot
|
@@ -90,7 +94,7 @@ module RIO
|
|
90
94
|
def rm(*args) rtn_self { ; } end
|
91
95
|
alias delete rm
|
92
96
|
alias delete! rm
|
93
|
-
def touch(*args) rtn_reset {
|
97
|
+
def touch(*args) rtn_reset { fs.touch(self,*args) } end
|
94
98
|
end
|
95
99
|
end
|
96
100
|
end
|
data/lib/rio/ops/path.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# ===============================================================================
|
3
|
-
# Copyright (c) 2005, Christopher Kleckner
|
3
|
+
# Copyright (c) 2005, 2006 Christopher Kleckner
|
4
4
|
# All rights reserved
|
5
5
|
#
|
6
6
|
# This file is part of the Rio library for ruby.
|
@@ -22,7 +22,7 @@
|
|
22
22
|
#++
|
23
23
|
#
|
24
24
|
# To create the documentation for Rio run the command
|
25
|
-
#
|
25
|
+
# ruby build_doc.rb
|
26
26
|
# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
|
27
27
|
#
|
28
28
|
# Suggested Reading
|
@@ -35,47 +35,49 @@
|
|
35
35
|
# The documented interface and behavior is subject to change without notice.</b>
|
36
36
|
|
37
37
|
|
38
|
-
require 'rio/impl/path'
|
38
|
+
#require 'rio/impl/path'
|
39
39
|
module RIO
|
40
40
|
module Ops #:nodoc: all
|
41
41
|
module Path
|
42
42
|
module Test
|
43
|
-
def blockdev?(*args)
|
44
|
-
def chardev?(*args)
|
45
|
-
def directory?(*args)
|
46
|
-
def exist?(*args)
|
47
|
-
def file?(*args)
|
48
|
-
|
49
|
-
|
50
|
-
def
|
43
|
+
def blockdev?(*args) fs.blockdev?(self.to_s,*args) end
|
44
|
+
def chardev?(*args) fs.chardev?(self.to_s,*args) end
|
45
|
+
def directory?(*args) fs.directory?(self.to_s,*args) end
|
46
|
+
def exist?(*args) fs.exist?(self.to_s,*args) end
|
47
|
+
def file?(*args)
|
48
|
+
fs.file?(self.to_s,*args)
|
49
|
+
end
|
50
|
+
def pipe?(*args) fs.pipe?(self.to_s,*args) end
|
51
|
+
def socket?(*args) fs.socket?(self.to_s,*args) end
|
52
|
+
def symlink?(*args) fs.symlink?(self.to_s,*args) end
|
51
53
|
alias :dir? :directory?
|
52
54
|
def open?() not self.closed? end
|
53
55
|
def closed?() self.ioh.nil? end
|
54
56
|
end
|
55
57
|
module Status
|
56
58
|
include Test
|
57
|
-
def fnmatch(*args)
|
58
|
-
def fnmatch?(*args)
|
59
|
-
def ftype(*args)
|
60
|
-
def stat(*args)
|
61
|
-
def atime(*args)
|
62
|
-
def ctime(*args)
|
63
|
-
def mtime(*args)
|
64
|
-
def executable?(*args)
|
65
|
-
def executable_real?(*args)
|
66
|
-
def readable?(*args)
|
67
|
-
def readable_real?(*args)
|
68
|
-
def writable?(*args)
|
69
|
-
def writable_real?(*args)
|
70
|
-
def sticky?(*args)
|
71
|
-
def owned?(*args)
|
72
|
-
def grpowned?(*args)
|
73
|
-
def setgid?(*args)
|
74
|
-
def setuid?(*args)
|
75
|
-
def size(*args)
|
76
|
-
def size?(*args)
|
77
|
-
def zero?(*args)
|
78
|
-
def root?(*args)
|
59
|
+
def fnmatch(*args) fs.fnmatch(self.to_s,*args) end
|
60
|
+
def fnmatch?(*args) fs.fnmatch?(self.to_s,*args) end
|
61
|
+
def ftype(*args) fs.ftype(self.to_s,*args) end
|
62
|
+
def stat(*args) fs.stat(self.to_s,*args) end
|
63
|
+
def atime(*args) fs.atime(self.to_s,*args) end
|
64
|
+
def ctime(*args) fs.ctime(self.to_s,*args) end
|
65
|
+
def mtime(*args) fs.mtime(self.to_s,*args) end
|
66
|
+
def executable?(*args) fs.executable?(self.to_s,*args) end
|
67
|
+
def executable_real?(*args) fs.executable_real?(self.to_s,*args) end
|
68
|
+
def readable?(*args) fs.readable?(self.to_s,*args) end
|
69
|
+
def readable_real?(*args) fs.readable_real?(self.to_s,*args) end
|
70
|
+
def writable?(*args) fs.writable?(self.to_s,*args) end
|
71
|
+
def writable_real?(*args) fs.writable_real?(self.to_s,*args) end
|
72
|
+
def sticky?(*args) fs.sticky?(self.to_s,*args) end
|
73
|
+
def owned?(*args) fs.owned?(self.to_s,*args) end
|
74
|
+
def grpowned?(*args) fs.grpowned?(self.to_s,*args) end
|
75
|
+
def setgid?(*args) fs.setgid?(self.to_s,*args) end
|
76
|
+
def setuid?(*args) fs.setuid?(self.to_s,*args) end
|
77
|
+
def size(*args) fs.size(self.to_s,*args) end
|
78
|
+
def size?(*args) fs.size?(self.to_s,*args) end
|
79
|
+
def zero?(*args) fs.zero?(self.to_s,*args) end
|
80
|
+
def root?(*args) fs.root?(self.to_s) end
|
79
81
|
|
80
82
|
end
|
81
83
|
module URI
|
@@ -131,17 +133,17 @@ module RIO
|
|
131
133
|
module Query
|
132
134
|
def expand_path(*args)
|
133
135
|
args[0] = args[0].to_s unless args.empty?
|
134
|
-
new_rio(RL.fs2url(
|
136
|
+
new_rio(RL.fs2url(fs.expand_path(self.to_s,*args)))
|
135
137
|
end
|
136
138
|
def extname(*args)
|
137
|
-
en =
|
139
|
+
en = fs.extname(rl.path_no_slash,*args)
|
138
140
|
(en.empty? ? nil : en)
|
139
141
|
end
|
140
142
|
def split()
|
141
143
|
require 'rio/to_rio'
|
142
144
|
parts = self.rl.split
|
143
145
|
# map to rios and extend the array with to_array
|
144
|
-
parts.map { |arl|
|
146
|
+
parts.map { |arl| new_rio(arl) }.extend(ToRio::Array)
|
145
147
|
end
|
146
148
|
def basename(*args)
|
147
149
|
unless args.empty?
|
@@ -149,15 +151,15 @@ module RIO
|
|
149
151
|
self.ext(ex)
|
150
152
|
end
|
151
153
|
#p self.ext?.inspect
|
152
|
-
fn =
|
154
|
+
fn = fs.basename(rl.path_no_slash,self.ext?)
|
153
155
|
new_rio(fn,{:base => _calc_base()})
|
154
156
|
end
|
155
157
|
def filename()
|
156
|
-
fn =
|
158
|
+
fn = fs.basename(rl.path_no_slash)
|
157
159
|
new_rio(fn,{:base => _calc_base()})
|
158
160
|
end
|
159
161
|
def _calc_base()
|
160
|
-
dn =
|
162
|
+
dn = fs.dirname(rl.path_no_slash)
|
161
163
|
dn[0] == ?/ ? dn : self.base.to_url + dn + '/' #'
|
162
164
|
# if dn[0] == ?/
|
163
165
|
# dn
|
@@ -168,7 +170,7 @@ module RIO
|
|
168
170
|
private :_calc_base
|
169
171
|
|
170
172
|
def dirname(*args)
|
171
|
-
#new_rio(
|
173
|
+
#new_rio(fs.dirname(rl.path_no_slash,*args))
|
172
174
|
new_rio(rl.dirname)
|
173
175
|
end
|
174
176
|
|
@@ -278,10 +280,10 @@ module RIO
|
|
278
280
|
dst = self.ensure_rio(d)
|
279
281
|
dst /= self.filename if dst.directory?
|
280
282
|
if self.abs?
|
281
|
-
|
283
|
+
fs.symlink(self,dst)
|
282
284
|
else
|
283
285
|
#p "symlink(#{dst.route_to(self)},#{dst})"
|
284
|
-
|
286
|
+
fs.symlink(dst.route_to(self),dst.to_s)
|
285
287
|
end
|
286
288
|
dst.reset
|
287
289
|
}
|
@@ -312,4 +314,4 @@ module RIO
|
|
312
314
|
end
|
313
315
|
|
314
316
|
end
|
315
|
-
end
|
317
|
+
end
|