8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/rpl/words/filesystem.rb', line 8
def populate_dictionary
super
category = 'Filesystem'
@dictionary.add_word!( ['fread'],
category,
'( filename -- content ) read file and put content on stack as string',
proc do
args = ( [[RplString]] )
path = File.expand_path( args[0].value )
@stack << Types.new_object( RplString, "\"#{File.read( path )}\"" )
end )
@dictionary.add_word!( ['feval'],
category,
'( filename -- … ) read and run file',
Types.new_object( RplProgram, '« fread eval »' ) )
@dictionary.add_word!( ['fwrite'],
category,
'( content filename -- ) write content into filename',
proc do
args = ( [[RplString], :any] )
File.write( File.expand_path( args[0].value ),
args[1].value )
end )
end
|