mmap 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Changes +55 -0
- data/Manifest.txt +11 -0
- data/README.rdoc +36 -0
- data/Rakefile +27 -0
- data/b.rb +33 -0
- data/ext/mmap/extconf.rb +32 -0
- data/ext/mmap/mmap.c +2624 -0
- data/lib/mmap.rb +22 -0
- data/mmap.html +272 -0
- data/mmap.rd +253 -0
- data/test/test_mmap.rb +367 -0
- metadata +88 -0
data/lib/mmap.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# The Mmap class implement memory-mapped file objects
|
2
|
+
#
|
3
|
+
# Most of these methods have the same syntax than the methods of String
|
4
|
+
#
|
5
|
+
# === WARNING
|
6
|
+
# === The variables $' and $` are not available with gsub! and sub!
|
7
|
+
require 'mmap/mmap'
|
8
|
+
|
9
|
+
class Mmap
|
10
|
+
include Comparable
|
11
|
+
include Enumerable
|
12
|
+
|
13
|
+
VERSION = '0.2.6'
|
14
|
+
|
15
|
+
def clone # :nodoc:
|
16
|
+
raise TypeError, "can't clone instance of #{self.class}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def dup # :nodoc:
|
20
|
+
raise TypeError, "can't dup instance of #{self.class}"
|
21
|
+
end
|
22
|
+
end
|
data/mmap.html
ADDED
@@ -0,0 +1,272 @@
|
|
1
|
+
<?xml version="1.0" ?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
6
|
+
<head>
|
7
|
+
<title>Untitled</title>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<h1><a name="label-0" id="label-0">Mmap</a></h1><!-- RDLabel: "Mmap" -->
|
11
|
+
<p><a href="ftp://moulon.inra.fr/pub/ruby/">Download</a></p>
|
12
|
+
<p>The Mmap class implement memory-mapped file objects</p>
|
13
|
+
<h3><a name="label-1" id="label-1">WARNING</a></h3><!-- RDLabel: "WARNING" -->
|
14
|
+
<h3><a name="label-2" id="label-2">The variables $' and $` are not available with gsub! and sub!</a></h3><!-- RDLabel: "The variables $' and $` are not available with gsub! and sub!" -->
|
15
|
+
<h2><a name="label-3" id="label-3">SuperClass</a></h2><!-- RDLabel: "SuperClass" -->
|
16
|
+
<p>Object</p>
|
17
|
+
<h2><a name="label-4" id="label-4">Included Modules</a></h2><!-- RDLabel: "Included Modules" -->
|
18
|
+
<ul>
|
19
|
+
<li>Comparable</li>
|
20
|
+
<li>Enumerable</li>
|
21
|
+
</ul>
|
22
|
+
<h2><a name="label-5" id="label-5">Class Methods</a></h2><!-- RDLabel: "Class Methods" -->
|
23
|
+
<dl>
|
24
|
+
<dt><a name="label-6" id="label-6"><code>lockall(<var>flag</var>)</code></a></dt><!-- RDLabel: "lockall" -->
|
25
|
+
<dd>
|
26
|
+
disable paging of all pages mapped. <var>flag</var> can be
|
27
|
+
<var>Mmap::MCL_CURRENT</var> or <var>Mmap::MCL_FUTURE</var></dd>
|
28
|
+
<dt><a name="label-7" id="label-7"><code>new(<var>file</var>, <var>mode</var> = "<var>r</var>", <var>protection</var> = <var>Mmap</var>::<var>MAP_SHARED</var>, <var>options</var> = {})</code></a></dt><!-- RDLabel: "new" -->
|
29
|
+
<dt><a name="label-8" id="label-8"><code>new(<var>nil</var>, <var>length</var>, <var>protection</var> = <var>Mmap</var>::<var>MAP_SHARED</var>, <var>options</var> = {})</code></a></dt><!-- RDLabel: "new" -->
|
30
|
+
<dd>
|
31
|
+
create a new Mmap object
|
32
|
+
<dl>
|
33
|
+
<dt><a name="label-9" id="label-9"><var>file</var></a></dt><!-- RDLabel: "file" -->
|
34
|
+
<dd>
|
35
|
+
Pathname of the file, if <var>nil</var> is given an anonymous map
|
36
|
+
is created <var>Mmanp::MAP_ANON</var>
|
37
|
+
</dd>
|
38
|
+
<dt><a name="label-10" id="label-10"><var>mode</var></a></dt><!-- RDLabel: "mode" -->
|
39
|
+
<dd>
|
40
|
+
Mode to open the file, it can be "r", "w", "rw", "a"
|
41
|
+
</dd>
|
42
|
+
<dt><a name="label-11" id="label-11"><var>protection</var></a></dt><!-- RDLabel: "protection" -->
|
43
|
+
<dd>
|
44
|
+
specify the nature of the mapping
|
45
|
+
<dl>
|
46
|
+
<dt><a name="label-12" id="label-12"><var>Mmap::MAP_SHARED</var></a></dt><!-- RDLabel: "Mmap::MAP_SHARED" -->
|
47
|
+
<dd>
|
48
|
+
Creates a mapping that's shared with all other processes
|
49
|
+
mapping the same areas of the file.
|
50
|
+
The default value is <var>Mmap::MAP_SHARED</var>
|
51
|
+
</dd>
|
52
|
+
<dt><a name="label-13" id="label-13"><var>Mmap::MAP_PRIVATE</var></a></dt><!-- RDLabel: "Mmap::MAP_PRIVATE" -->
|
53
|
+
<dd>
|
54
|
+
Creates a private copy-on-write mapping, so changes to the
|
55
|
+
contents of the mmap object will be private to this process
|
56
|
+
</dd>
|
57
|
+
</dl>
|
58
|
+
</dd>
|
59
|
+
<dt><a name="label-14" id="label-14"><var>options</var></a></dt><!-- RDLabel: "options" -->
|
60
|
+
<dd>
|
61
|
+
Hash. If one of the options <var>length</var> or <var>offset</var>
|
62
|
+
is specified it will not possible to modify the size of
|
63
|
+
the mapped file.
|
64
|
+
<dl>
|
65
|
+
<dt><a name="label-15" id="label-15"><var>length</var></a></dt><!-- RDLabel: "length" -->
|
66
|
+
<dd>
|
67
|
+
Maps <var>length</var> bytes from the file
|
68
|
+
</dd>
|
69
|
+
<dt><a name="label-16" id="label-16"><var>offset</var></a></dt><!-- RDLabel: "offset" -->
|
70
|
+
<dd>
|
71
|
+
The mapping begin at <var>offset</var>
|
72
|
+
</dd>
|
73
|
+
<dt><a name="label-17" id="label-17"><var>advice</var></a></dt><!-- RDLabel: "advice" -->
|
74
|
+
<dd>
|
75
|
+
The type of the access (see #madvise)
|
76
|
+
</dd>
|
77
|
+
</dl>
|
78
|
+
</dd>
|
79
|
+
</dl></dd>
|
80
|
+
<dt><a name="label-18" id="label-18"><code>unlockall</code></a></dt><!-- RDLabel: "unlockall" -->
|
81
|
+
<dd>
|
82
|
+
reenable paging</dd>
|
83
|
+
</dl>
|
84
|
+
<h2><a name="label-19" id="label-19">Methods</a></h2><!-- RDLabel: "Methods" -->
|
85
|
+
<dl>
|
86
|
+
<dt><a name="label-20" id="label-20"><code>extend(<var>count</var>)</code></a></dt><!-- RDLabel: "extend" -->
|
87
|
+
<dd>
|
88
|
+
add <var>count</var> bytes to the file (i.e. pre-extend the file) </dd>
|
89
|
+
<dt><a name="label-21" id="label-21"><code>madvise(<var>advice</var>)</code></a></dt><!-- RDLabel: "madvise" -->
|
90
|
+
<dd>
|
91
|
+
<var>advice</var> can have the value <var>Mmap::MADV_NORMAL</var>,
|
92
|
+
<var>Mmap::MADV_RANDOM</var>, <var>Mmap::MADV_SEQUENTIAL</var>,
|
93
|
+
<var>Mmap::MADV_WILLNEED</var>, <var>Mmap::MADV_DONTNEED</var></dd>
|
94
|
+
<dt><a name="label-22" id="label-22"><code>mprotect(<var>mode</var>)</code></a></dt><!-- RDLabel: "mprotect" -->
|
95
|
+
<dd>
|
96
|
+
change the mode, value must be "r", "w" or "rw"</dd>
|
97
|
+
<dt><a name="label-23" id="label-23"><code>mlock</code></a></dt><!-- RDLabel: "mlock" -->
|
98
|
+
<dd>
|
99
|
+
disable paging</dd>
|
100
|
+
<dt><a name="label-24" id="label-24"><code>msync</code></a></dt><!-- RDLabel: "msync" -->
|
101
|
+
<dt><a name="label-25" id="label-25"><code>flush</code></a></dt><!-- RDLabel: "flush" -->
|
102
|
+
<dd>
|
103
|
+
flush the file</dd>
|
104
|
+
<dt><a name="label-26" id="label-26"><code>munlock</code></a></dt><!-- RDLabel: "munlock" -->
|
105
|
+
<dd>
|
106
|
+
reenable paging</dd>
|
107
|
+
<dt><a name="label-27" id="label-27"><code>munmap</code></a></dt><!-- RDLabel: "munmap" -->
|
108
|
+
<dd>
|
109
|
+
terminate the association</dd>
|
110
|
+
</dl>
|
111
|
+
<h3><a name="label-28" id="label-28">Other methods with the same syntax than for the class String</a></h3><!-- RDLabel: "Other methods with the same syntax than for the class String" -->
|
112
|
+
<dl>
|
113
|
+
<dt><a name="label-29" id="label-29"><code><var>self</var> == <var>other</var></code></a></dt><!-- RDLabel: "self == other" -->
|
114
|
+
<dd>
|
115
|
+
comparison</dd>
|
116
|
+
<dt><a name="label-30" id="label-30"><code><var>self</var> > <var>other</var></code></a></dt><!-- RDLabel: "self > other" -->
|
117
|
+
<dd>
|
118
|
+
comparison</dd>
|
119
|
+
<dt><a name="label-31" id="label-31"><code><var>self</var> >= <var>other</var></code></a></dt><!-- RDLabel: "self >= other" -->
|
120
|
+
<dd>
|
121
|
+
comparison</dd>
|
122
|
+
<dt><a name="label-32" id="label-32"><code><var>self</var> < <var>other</var></code></a></dt><!-- RDLabel: "self < other" -->
|
123
|
+
<dd>
|
124
|
+
comparison</dd>
|
125
|
+
<dt><a name="label-33" id="label-33"><code><var>self</var> <= <var>other</var></code></a></dt><!-- RDLabel: "self <= other" -->
|
126
|
+
<dd>
|
127
|
+
comparison</dd>
|
128
|
+
<dt><a name="label-34" id="label-34"><code><var>self</var> === <var>other</var></code></a></dt><!-- RDLabel: "self === other" -->
|
129
|
+
<dd>
|
130
|
+
used for <var>case</var> comparison</dd>
|
131
|
+
<dt><a name="label-35" id="label-35"><code><var>self</var> << <var>other</var></code></a></dt><!-- RDLabel: "self << other" -->
|
132
|
+
<dd>
|
133
|
+
append <var>other</var> to <var>self</var></dd>
|
134
|
+
<dt><a name="label-36" id="label-36"><code><var>self</var> =~ <var>other</var></code></a></dt><!-- RDLabel: "self =~ other" -->
|
135
|
+
<dd>
|
136
|
+
return an index of the match </dd>
|
137
|
+
<dt><a name="label-37" id="label-37"><code>self[nth]</code></a></dt><!-- RDLabel: "self[nth]" -->
|
138
|
+
<dd>
|
139
|
+
retrieve the <var>nth</var> character</dd>
|
140
|
+
<dt><a name="label-38" id="label-38"><code>self[start..last]</code></a></dt><!-- RDLabel: "self[start..last]" -->
|
141
|
+
<dd>
|
142
|
+
return a substring from <var>start</var> to <var>last</var></dd>
|
143
|
+
<dt><a name="label-39" id="label-39"><code>self[start, <var>length</var>]</code></a></dt><!-- RDLabel: "self[start, length]" -->
|
144
|
+
<dd>
|
145
|
+
return a substring of <var>lenght</var> characters from <var>start</var> </dd>
|
146
|
+
<dt><a name="label-40" id="label-40"><code>self[nth] = <var>val</var></code></a></dt><!-- RDLabel: "self[nth] = val" -->
|
147
|
+
<dd>
|
148
|
+
change the <var>nth</var> character with <var>val</var></dd>
|
149
|
+
<dt><a name="label-41" id="label-41"><code>self[start..last] = <var>val</var></code></a></dt><!-- RDLabel: "self[start..last] = val" -->
|
150
|
+
<dd>
|
151
|
+
change substring from <var>start</var> to <var>last</var> with <var>val</var></dd>
|
152
|
+
<dt><a name="label-42" id="label-42"><code>self[start, <var>len</var>] = <var>val</var></code></a></dt><!-- RDLabel: "self[start, len] = val" -->
|
153
|
+
<dd>
|
154
|
+
replace <var>length</var> characters from <var>start</var> with <var>val</var>.</dd>
|
155
|
+
<dt><a name="label-43" id="label-43"><code><var>self</var> <=> <var>other</var></code></a></dt><!-- RDLabel: "self <=> other" -->
|
156
|
+
<dd>
|
157
|
+
comparison : return -1, 0, 1</dd>
|
158
|
+
<dt><a name="label-44" id="label-44"><code>casecmp(<var>other</var>) >= <var>1</var>.<var>7</var>.<var>1</var></code></a></dt><!-- RDLabel: "casecmp" -->
|
159
|
+
<dt><a name="label-45" id="label-45"><code>concat(<var>other</var>)</code></a></dt><!-- RDLabel: "concat" -->
|
160
|
+
<dd>
|
161
|
+
append the contents of <var>other</var></dd>
|
162
|
+
<dt><a name="label-46" id="label-46"><code>capitalize!</code></a></dt><!-- RDLabel: "capitalize!" -->
|
163
|
+
<dd>
|
164
|
+
change the first character to uppercase letter</dd>
|
165
|
+
<dt><a name="label-47" id="label-47"><code>chop!</code></a></dt><!-- RDLabel: "chop!" -->
|
166
|
+
<dd>
|
167
|
+
chop off the last character</dd>
|
168
|
+
<dt><a name="label-48" id="label-48"><code>chomp!([<var>rs</var>])</code></a></dt><!-- RDLabel: "chomp!" -->
|
169
|
+
<dd>
|
170
|
+
chop off the line ending character, specified by <var>rs</var></dd>
|
171
|
+
<dt><a name="label-49" id="label-49"><code>count(<var>o1</var> [, <var>o2</var>, ...])</code></a></dt><!-- RDLabel: "count" -->
|
172
|
+
<dd>
|
173
|
+
each parameter defines a set of character to count</dd>
|
174
|
+
<dt><a name="label-50" id="label-50"><code>crypt(<var>salt</var>)</code></a></dt><!-- RDLabel: "crypt" -->
|
175
|
+
<dd>
|
176
|
+
crypt with <var>salt</var> </dd>
|
177
|
+
<dt><a name="label-51" id="label-51"><code>delete!(<var>str</var>)</code></a></dt><!-- RDLabel: "delete!" -->
|
178
|
+
<dd>
|
179
|
+
delete every characters included in <var>str</var></dd>
|
180
|
+
<dt><a name="label-52" id="label-52"><code>downcase!</code></a></dt><!-- RDLabel: "downcase!" -->
|
181
|
+
<dd>
|
182
|
+
change all uppercase character to lowercase character</dd>
|
183
|
+
<dt><a name="label-53" id="label-53"><code>each_byte {|<var>char</var>|...}</code></a></dt><!-- RDLabel: "each_byte" -->
|
184
|
+
<dd>
|
185
|
+
iterate on each byte</dd>
|
186
|
+
<dt><a name="label-54" id="label-54"><code>each([<var>rs</var>]) {|<var>line</var>|...}</code></a></dt><!-- RDLabel: "each" -->
|
187
|
+
<dt><a name="label-55" id="label-55"><code>each_line([<var>rs</var>]) {|<var>line</var>|...}</code></a></dt><!-- RDLabel: "each_line" -->
|
188
|
+
<dd>
|
189
|
+
iterate on each line</dd>
|
190
|
+
<dt><a name="label-56" id="label-56"><code>empty?</code></a></dt><!-- RDLabel: "empty?" -->
|
191
|
+
<dd>
|
192
|
+
return <var>true</var> if the file is empty</dd>
|
193
|
+
<dt><a name="label-57" id="label-57"><code>freeze</code></a></dt><!-- RDLabel: "freeze" -->
|
194
|
+
<dd>
|
195
|
+
freeze the current file </dd>
|
196
|
+
<dt><a name="label-58" id="label-58"><code>frozen</code></a></dt><!-- RDLabel: "frozen" -->
|
197
|
+
<dd>
|
198
|
+
return <var>true</var> if the file is frozen</dd>
|
199
|
+
<dt><a name="label-59" id="label-59"><code>gsub!(<var>pattern</var>, <var>replace</var>)</code></a></dt><!-- RDLabel: "gsub!" -->
|
200
|
+
<dd>
|
201
|
+
global substitution</dd>
|
202
|
+
<dt><a name="label-60" id="label-60"><code>gsub!(<var>pattern</var>) {|<var>str</var>|...}</code></a></dt><!-- RDLabel: "gsub!" -->
|
203
|
+
<dd>
|
204
|
+
global substitution</dd>
|
205
|
+
<dt><a name="label-61" id="label-61"><code>include?(<var>other</var>)</code></a></dt><!-- RDLabel: "include?" -->
|
206
|
+
<dd>
|
207
|
+
return <var>true</var> if <var>other</var> is found</dd>
|
208
|
+
<dt><a name="label-62" id="label-62"><code>index(<var>substr</var>[, <var>pos</var>])</code></a></dt><!-- RDLabel: "index" -->
|
209
|
+
<dd>
|
210
|
+
return the index of <var>substr</var> </dd>
|
211
|
+
<dt><a name="label-63" id="label-63"><code>insert(<var>index</var>, <var>str</var>) >= <var>1</var>.<var>7</var>.<var>1</var></code></a></dt><!-- RDLabel: "insert" -->
|
212
|
+
<dd>
|
213
|
+
insert <var>str</var> at <var>index</var></dd>
|
214
|
+
<dt><a name="label-64" id="label-64"><code>length</code></a></dt><!-- RDLabel: "length" -->
|
215
|
+
<dd>
|
216
|
+
return the size of the file</dd>
|
217
|
+
<dt><a name="label-65" id="label-65"><code>reverse!</code></a></dt><!-- RDLabel: "reverse!" -->
|
218
|
+
<dd>
|
219
|
+
reverse the content of the file </dd>
|
220
|
+
<dt><a name="label-66" id="label-66"><code>rindex(<var>substr</var>[, <var>pos</var>])</code></a></dt><!-- RDLabel: "rindex" -->
|
221
|
+
<dd>
|
222
|
+
return the index of the last occurrence of <var>substr</var></dd>
|
223
|
+
<dt><a name="label-67" id="label-67"><code>scan(<var>pattern</var>)</code></a></dt><!-- RDLabel: "scan" -->
|
224
|
+
<dd>
|
225
|
+
return an array of all occurence matched by <var>pattern</var> </dd>
|
226
|
+
<dt><a name="label-68" id="label-68"><code>scan(<var>pattern</var>) {|<var>str</var>| ...}</code></a></dt><!-- RDLabel: "scan" -->
|
227
|
+
<dd>
|
228
|
+
iterate through the file, matching the <var>pattern</var></dd>
|
229
|
+
<dt><a name="label-69" id="label-69"><code>size</code></a></dt><!-- RDLabel: "size" -->
|
230
|
+
<dd>
|
231
|
+
return the size of the file</dd>
|
232
|
+
<dt><a name="label-70" id="label-70"><code>slice</code></a></dt><!-- RDLabel: "slice" -->
|
233
|
+
<dd>
|
234
|
+
same than <var>[]</var></dd>
|
235
|
+
<dt><a name="label-71" id="label-71"><code>slice!</code></a></dt><!-- RDLabel: "slice!" -->
|
236
|
+
<dd>
|
237
|
+
delete the specified portion of the file</dd>
|
238
|
+
<dt><a name="label-72" id="label-72"><code>split([<var>sep</var>[, <var>limit</var>]])</code></a></dt><!-- RDLabel: "split" -->
|
239
|
+
<dd>
|
240
|
+
splits into a list of strings and return this array</dd>
|
241
|
+
<dt><a name="label-73" id="label-73"><code>squeeze!([<var>str</var>])</code></a></dt><!-- RDLabel: "squeeze!" -->
|
242
|
+
<dd>
|
243
|
+
squeezes sequences of the same characters which is included in <var>str</var></dd>
|
244
|
+
<dt><a name="label-74" id="label-74"><code>strip!</code></a></dt><!-- RDLabel: "strip!" -->
|
245
|
+
<dd>
|
246
|
+
removes leading and trailing whitespace</dd>
|
247
|
+
<dt><a name="label-75" id="label-75"><code>sub!(<var>pattern</var>, <var>replace</var>)</code></a></dt><!-- RDLabel: "sub!" -->
|
248
|
+
<dd>
|
249
|
+
substitution </dd>
|
250
|
+
<dt><a name="label-76" id="label-76"><code>sub!(<var>pattern</var>) {|<var>str</var>| ...}</code></a></dt><!-- RDLabel: "sub!" -->
|
251
|
+
<dd>
|
252
|
+
substitution</dd>
|
253
|
+
<dt><a name="label-77" id="label-77"><code>sum([<var>bits</var>])</code></a></dt><!-- RDLabel: "sum" -->
|
254
|
+
<dd>
|
255
|
+
return a checksum</dd>
|
256
|
+
<dt><a name="label-78" id="label-78"><code>swapcase!</code></a></dt><!-- RDLabel: "swapcase!" -->
|
257
|
+
<dd>
|
258
|
+
replaces all lowercase characters to uppercase characters, and vice-versa</dd>
|
259
|
+
<dt><a name="label-79" id="label-79"><code>tr!(<var>search</var>, <var>replace</var>)</code></a></dt><!-- RDLabel: "tr!" -->
|
260
|
+
<dd>
|
261
|
+
translate the character from <var>search</var> to <var>replace</var> </dd>
|
262
|
+
<dt><a name="label-80" id="label-80"><code>tr_s!(<var>search</var>, <var>replace</var>)</code></a></dt><!-- RDLabel: "tr_s!" -->
|
263
|
+
<dd>
|
264
|
+
translate the character from <var>search</var> to <var>replace</var>, then
|
265
|
+
squeeze sequence of the same characters </dd>
|
266
|
+
<dt><a name="label-81" id="label-81"><code>upcase!</code></a></dt><!-- RDLabel: "upcase!" -->
|
267
|
+
<dd>
|
268
|
+
replaces all lowercase characters to downcase characters</dd>
|
269
|
+
</dl>
|
270
|
+
|
271
|
+
</body>
|
272
|
+
</html>
|
data/mmap.rd
ADDED
@@ -0,0 +1,253 @@
|
|
1
|
+
=begin
|
2
|
+
= Mmap
|
3
|
+
|
4
|
+
((<Download|URL:ftp://moulon.inra.fr/pub/ruby/>))
|
5
|
+
|
6
|
+
The Mmap class implement memory-mapped file objects
|
7
|
+
|
8
|
+
=== WARNING
|
9
|
+
=== The variables $' and $` are not available with gsub! and sub!
|
10
|
+
|
11
|
+
== SuperClass
|
12
|
+
|
13
|
+
Object
|
14
|
+
|
15
|
+
== Included Modules
|
16
|
+
|
17
|
+
* Comparable
|
18
|
+
* Enumerable
|
19
|
+
|
20
|
+
== Class Methods
|
21
|
+
|
22
|
+
--- lockall(flag)
|
23
|
+
disable paging of all pages mapped. ((|flag|)) can be
|
24
|
+
((|Mmap::MCL_CURRENT|)) or ((|Mmap::MCL_FUTURE|))
|
25
|
+
|
26
|
+
--- new(file, mode = "r", protection = Mmap::MAP_SHARED, options = {})
|
27
|
+
--- new(nil, length, protection = Mmap::MAP_SHARED, options = {})
|
28
|
+
create a new Mmap object
|
29
|
+
|
30
|
+
: ((|file|))
|
31
|
+
Pathname of the file, if ((|nil|)) is given an anonymous map
|
32
|
+
is created ((|Mmanp::MAP_ANON|))
|
33
|
+
|
34
|
+
: ((|mode|))
|
35
|
+
Mode to open the file, it can be "r", "w", "rw", "a"
|
36
|
+
|
37
|
+
: ((|protection|))
|
38
|
+
specify the nature of the mapping
|
39
|
+
|
40
|
+
: ((|Mmap::MAP_SHARED|))
|
41
|
+
Creates a mapping that's shared with all other processes
|
42
|
+
mapping the same areas of the file.
|
43
|
+
The default value is ((|Mmap::MAP_SHARED|))
|
44
|
+
|
45
|
+
: ((|Mmap::MAP_PRIVATE|))
|
46
|
+
Creates a private copy-on-write mapping, so changes to the
|
47
|
+
contents of the mmap object will be private to this process
|
48
|
+
|
49
|
+
: ((|options|))
|
50
|
+
Hash. If one of the options ((|length|)) or ((|offset|))
|
51
|
+
is specified it will not possible to modify the size of
|
52
|
+
the mapped file.
|
53
|
+
|
54
|
+
: ((|length|))
|
55
|
+
Maps ((|length|)) bytes from the file
|
56
|
+
|
57
|
+
: ((|offset|))
|
58
|
+
The mapping begin at ((|offset|))
|
59
|
+
|
60
|
+
: ((|advice|))
|
61
|
+
The type of the access (see #madvise)
|
62
|
+
|
63
|
+
|
64
|
+
--- unlockall
|
65
|
+
reenable paging
|
66
|
+
|
67
|
+
== Methods
|
68
|
+
|
69
|
+
--- extend(count)
|
70
|
+
add ((|count|)) bytes to the file (i.e. pre-extend the file)
|
71
|
+
|
72
|
+
--- madvise(advice)
|
73
|
+
((|advice|)) can have the value ((|Mmap::MADV_NORMAL|)),
|
74
|
+
((|Mmap::MADV_RANDOM|)), ((|Mmap::MADV_SEQUENTIAL|)),
|
75
|
+
((|Mmap::MADV_WILLNEED|)), ((|Mmap::MADV_DONTNEED|))
|
76
|
+
|
77
|
+
--- mprotect(mode)
|
78
|
+
change the mode, value must be "r", "w" or "rw"
|
79
|
+
|
80
|
+
--- mlock
|
81
|
+
disable paging
|
82
|
+
|
83
|
+
--- msync
|
84
|
+
--- flush
|
85
|
+
flush the file
|
86
|
+
|
87
|
+
--- munlock
|
88
|
+
reenable paging
|
89
|
+
|
90
|
+
--- munmap
|
91
|
+
terminate the association
|
92
|
+
|
93
|
+
=== Other methods with the same syntax than for the class String
|
94
|
+
|
95
|
+
|
96
|
+
--- self == other
|
97
|
+
comparison
|
98
|
+
|
99
|
+
--- self > other
|
100
|
+
comparison
|
101
|
+
|
102
|
+
--- self >= other
|
103
|
+
comparison
|
104
|
+
|
105
|
+
--- self < other
|
106
|
+
comparison
|
107
|
+
|
108
|
+
--- self <= other
|
109
|
+
comparison
|
110
|
+
|
111
|
+
--- self === other
|
112
|
+
used for ((|case|)) comparison
|
113
|
+
|
114
|
+
--- self << other
|
115
|
+
append ((|other|)) to ((|self|))
|
116
|
+
|
117
|
+
--- self =~ other
|
118
|
+
return an index of the match
|
119
|
+
|
120
|
+
--- self[nth]
|
121
|
+
retrieve the ((|nth|)) character
|
122
|
+
|
123
|
+
--- self[start..last]
|
124
|
+
return a substring from ((|start|)) to ((|last|))
|
125
|
+
|
126
|
+
--- self[start, length]
|
127
|
+
return a substring of ((|lenght|)) characters from ((|start|))
|
128
|
+
|
129
|
+
--- self[nth] = val
|
130
|
+
change the ((|nth|)) character with ((|val|))
|
131
|
+
|
132
|
+
--- self[start..last] = val
|
133
|
+
change substring from ((|start|)) to ((|last|)) with ((|val|))
|
134
|
+
|
135
|
+
--- self[start, len] = val
|
136
|
+
replace ((|length|)) characters from ((|start|)) with ((|val|)).
|
137
|
+
|
138
|
+
--- self <=> other
|
139
|
+
comparison : return -1, 0, 1
|
140
|
+
|
141
|
+
--- casecmp(other) >= 1.7.1
|
142
|
+
|
143
|
+
--- concat(other)
|
144
|
+
append the contents of ((|other|))
|
145
|
+
|
146
|
+
--- capitalize!
|
147
|
+
change the first character to uppercase letter
|
148
|
+
|
149
|
+
--- chop!
|
150
|
+
chop off the last character
|
151
|
+
|
152
|
+
--- chomp!([rs])
|
153
|
+
chop off the line ending character, specified by ((|rs|))
|
154
|
+
|
155
|
+
--- count(o1 [, o2, ...])
|
156
|
+
each parameter defines a set of character to count
|
157
|
+
|
158
|
+
--- crypt(salt)
|
159
|
+
crypt with ((|salt|))
|
160
|
+
|
161
|
+
--- delete!(str)
|
162
|
+
delete every characters included in ((|str|))
|
163
|
+
|
164
|
+
--- downcase!
|
165
|
+
change all uppercase character to lowercase character
|
166
|
+
|
167
|
+
--- each_byte {|char|...}
|
168
|
+
iterate on each byte
|
169
|
+
|
170
|
+
--- each([rs]) {|line|...}
|
171
|
+
--- each_line([rs]) {|line|...}
|
172
|
+
iterate on each line
|
173
|
+
|
174
|
+
--- empty?
|
175
|
+
return ((|true|)) if the file is empty
|
176
|
+
|
177
|
+
--- freeze
|
178
|
+
freeze the current file
|
179
|
+
|
180
|
+
--- frozen
|
181
|
+
return ((|true|)) if the file is frozen
|
182
|
+
|
183
|
+
--- gsub!(pattern, replace)
|
184
|
+
global substitution
|
185
|
+
|
186
|
+
--- gsub!(pattern) {|str|...}
|
187
|
+
global substitution
|
188
|
+
|
189
|
+
--- include?(other)
|
190
|
+
return ((|true|)) if ((|other|)) is found
|
191
|
+
|
192
|
+
--- index(substr[, pos])
|
193
|
+
return the index of ((|substr|))
|
194
|
+
|
195
|
+
--- insert(index, str) >= 1.7.1
|
196
|
+
insert ((|str|)) at ((|index|))
|
197
|
+
|
198
|
+
--- length
|
199
|
+
return the size of the file
|
200
|
+
|
201
|
+
--- reverse!
|
202
|
+
reverse the content of the file
|
203
|
+
|
204
|
+
--- rindex(substr[, pos])
|
205
|
+
return the index of the last occurrence of ((|substr|))
|
206
|
+
|
207
|
+
--- scan(pattern)
|
208
|
+
return an array of all occurence matched by ((|pattern|))
|
209
|
+
|
210
|
+
--- scan(pattern) {|str| ...}
|
211
|
+
iterate through the file, matching the ((|pattern|))
|
212
|
+
|
213
|
+
--- size
|
214
|
+
return the size of the file
|
215
|
+
|
216
|
+
--- slice
|
217
|
+
same than ((|[]|))
|
218
|
+
|
219
|
+
--- slice!
|
220
|
+
delete the specified portion of the file
|
221
|
+
|
222
|
+
--- split([sep[, limit]])
|
223
|
+
splits into a list of strings and return this array
|
224
|
+
|
225
|
+
--- squeeze!([str])
|
226
|
+
squeezes sequences of the same characters which is included in ((|str|))
|
227
|
+
|
228
|
+
--- strip!
|
229
|
+
removes leading and trailing whitespace
|
230
|
+
|
231
|
+
--- sub!(pattern, replace)
|
232
|
+
substitution
|
233
|
+
|
234
|
+
--- sub!(pattern) {|str| ...}
|
235
|
+
substitution
|
236
|
+
|
237
|
+
--- sum([bits])
|
238
|
+
return a checksum
|
239
|
+
|
240
|
+
--- swapcase!
|
241
|
+
replaces all lowercase characters to uppercase characters, and vice-versa
|
242
|
+
|
243
|
+
--- tr!(search, replace)
|
244
|
+
translate the character from ((|search|)) to ((|replace|))
|
245
|
+
|
246
|
+
--- tr_s!(search, replace)
|
247
|
+
translate the character from ((|search|)) to ((|replace|)), then
|
248
|
+
squeeze sequence of the same characters
|
249
|
+
|
250
|
+
--- upcase!
|
251
|
+
replaces all lowercase characters to downcase characters
|
252
|
+
|
253
|
+
=end
|