OCaml: Handle some edge cases; refactor parser, main.ml; add config fetcher

This commit is contained in:
Juno Takano 2025-05-09 11:19:27 -03:00
commit cb56da1462
16 changed files with 229 additions and 105 deletions

View file

@ -1,3 +1,5 @@
open Utilities.Aliases
let read_channel channel =
let buffer = Buffer.create 4096 in
let rec read () =
@ -8,6 +10,12 @@ let read_channel channel =
in
try read () with End_of_file -> Buffer.contents buffer
let can_read (path: string): bool =
try Unix.access path [Unix.R_OK]; true
with Unix.Unix_error _ ->
elog $ "Failed to read file " ^ path;
false
let read path =
let channel = open_in path in
read_channel channel