add FREAD

This commit is contained in:
Gwenhael Le Moine 2021-12-15 13:33:52 +01:00
parent 080bac161f
commit f234dffa59
No known key found for this signature in database
GPG key ID: FDFE3669426707A7
2 changed files with 20 additions and 0 deletions

View file

@ -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
View 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