add FREAD
This commit is contained in:
parent
080bac161f
commit
f234dffa59
2 changed files with 20 additions and 0 deletions
|
@ -14,6 +14,7 @@ require_relative './core/test'
|
|||
require_relative './core/time-date'
|
||||
require_relative './core/trig'
|
||||
require_relative './core/logs'
|
||||
require_relative './core/filesystem'
|
||||
|
||||
module Rpl
|
||||
module Lang
|
||||
|
|
19
lib/core/filesystem.rb
Normal file
19
lib/core/filesystem.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
module Rpl
|
||||
module Lang
|
||||
module Core
|
||||
module_function
|
||||
|
||||
# ( filename -- content ) read file and put content on stack as string
|
||||
def fread( stack, dictionary )
|
||||
stack, args = Rpl::Lang::Core.stack_extract( stack, [%i[string]] )
|
||||
|
||||
path = File.absolute_path( args[0][:value][1..-2] )
|
||||
p path
|
||||
stack << { type: :string,
|
||||
value: File.read( path ) }
|
||||
|
||||
[stack, dictionary]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue