From 67ef7b5201b5b8ea90c6d75019343697dbb0755d Mon Sep 17 00:00:00 2001 From: Corentin Leruth Date: Tue, 21 May 2019 14:59:12 +0200 Subject: [PATCH] fix Unix.EACCES error (#99) --- library/Fs.re | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/library/Fs.re b/library/Fs.re index 5a46f51..061c395 100644 --- a/library/Fs.re +++ b/library/Fs.re @@ -26,12 +26,11 @@ let readdir = dir => { }; let writeFile = (path, contents) => { - let%lwt x = Lwt_unix.openfile(path, [Unix.O_RDWR, Unix.O_CREAT], 777); - let%lwt _ = - Lwt.finalize( - () => Lwt_unix.write_string(x, contents, 0, String.length(contents)), - () => Lwt_unix.close(x), - ); + let%lwt targetFile = Lwt_io.open_file(~mode=Lwt_io.Output, path); + + let%lwt () = Lwt_io.write(targetFile, contents); + let%lwt () = Lwt_io.close(targetFile); + Lwt.return(); }; @@ -46,4 +45,4 @@ let realpath = Filename.realpath; let try_readlink = path => try (Ok(Unix.readlink(path))) { | err => Error(err) - }; + }; \ No newline at end of file