OCaml: Handle some edge cases; refactor parser, main.ml; add config fetcher
This commit is contained in:
parent
6096817932
commit
cb56da1462
16 changed files with 229 additions and 105 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue