From 6ea5ed423f09cb7499202eccbd509419e7a64897 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Tue, 20 Dec 2022 01:13:56 +0100 Subject: [PATCH 1/3] Runtime: fix pseudo fs --- lib/tests/test_sys.ml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/tests/test_sys.ml b/lib/tests/test_sys.ml index ad9adc3744..07607be86b 100644 --- a/lib/tests/test_sys.ml +++ b/lib/tests/test_sys.ml @@ -101,3 +101,13 @@ let%expect_test _ = print_digest (Digest.channel c size); [%expect {| 573705548ab0d6c8a2193579611511a2 |}]; () + +let%expect_test _ = + print_digest (Digest.string content); + [%expect {| dd5da7fa373a2b2257d361aaf76845a0 |}]; + let c = open_out_bin "/static/temp0" in + output_string c content; + close_out c; + let content' = Sys_js.read_file ~name:"/static/temp0" in + assert (content' = content); + [%expect {||}] From 4f953b1496df3abf793cbba2e2290c34c7db767b Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Tue, 20 Dec 2022 08:37:42 +0100 Subject: [PATCH 2/3] Runtime: fix caml_read_file_content --- runtime/fs.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/fs.js b/runtime/fs.js index aa4968721d..58b272755a 100644 --- a/runtime/fs.js +++ b/runtime/fs.js @@ -322,7 +322,7 @@ function jsoo_create_file(name,content) { //Provides: caml_read_file_content -//Requires: resolve_fs_device, caml_raise_no_such_file, caml_create_bytes, caml_string_of_bytes +//Requires: resolve_fs_device, caml_raise_no_such_file, caml_string_of_array //Requires: caml_string_of_jsbytes, caml_jsbytes_of_string function caml_read_file_content (name) { var name = (typeof name == "string")?caml_string_of_jsbytes(name):name; @@ -330,9 +330,9 @@ function caml_read_file_content (name) { if(root.device.exists(root.rest)) { var file = root.device.open(root.rest,{rdonly:1}); var len = file.length(); - var buf = caml_create_bytes(len); + var buf = new Uint8Array(len); file.read(0,buf,0,len); - return caml_string_of_bytes(buf) + return caml_string_of_array(buf) } caml_raise_no_such_file(caml_jsbytes_of_string(name)); } From fb5ad2fa20ca549e917f916f51657506501cbb60 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Tue, 20 Dec 2022 08:39:44 +0100 Subject: [PATCH 3/3] Changes --- CHANGES.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 1401622ebe..abc1d18e38 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,9 @@ +# dev (202?-??-??) - ?? +## Features/Changes + +## Bug fixes +Runtime: fix caml_read_file_content + # 5.0.0 (2022-12-20) - Lille ## Features/Changes * Compiler: add support for effect handlers (--enable=effects)