File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import (
2323 "io"
2424 "iter"
2525 "net/http"
26+ "os"
2627 "sync"
2728 "time"
2829 "unsafe"
@@ -242,6 +243,16 @@ func roc_fx_get(url *RocStr) C.struct_ResultBytesString {
242243 return getResultSuccess (body )
243244}
244245
246+ //export roc_fx_file_read_bytes
247+ func roc_fx_file_read_bytes (path * RocStr ) C.struct_ResultBytesString {
248+ content , err := os .ReadFile (path .String ())
249+ if err != nil {
250+ return getResultError (err )
251+ }
252+
253+ return getResultSuccess (content )
254+ }
255+
245256func getResultError (err error ) C.struct_ResultBytesString {
246257 errStr := NewRocStr (err .Error ())
247258 payload := * (* [24 ]byte )(unsafe .Pointer (& errStr ))
Original file line number Diff line number Diff line change @@ -4,10 +4,12 @@ hosted Host
44 stdout_line!,
55 posix_time!,
66 get!,
7+ file_read_bytes!,
78 ]
89 imports []
910
1011save_event ! : List U8 => {}
1112stdout_line ! : Str => {}
1213posix_time ! : {} => U128
1314get ! : Str => Result (List U8 ) Str # TODO: Improve this
15+ file_read_bytes ! : Str => Result (List U8 ) Str
You can’t perform that action at this time.
0 commit comments