Skip to content

Commit

Permalink
Fixing paths passed to eio
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenldl committed Jun 29, 2024
1 parent c2667df commit 1aee502
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bin/BLAKE2B.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let hash_of_file ~env ~path =
let fs = Eio.Stdenv.fs env in
let ctx = ref B.empty in
try
Eio.Path.(with_open_in (fs / path))
Eio.Path.(with_open_in (fs / File_utils.fix_path_for_eio path))
(fun flow ->
match
Eio.Buf_read.parse ~max_size:Params.hash_chunk_size
Expand Down
10 changes: 8 additions & 2 deletions bin/document.ml
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,13 @@ let save_index ~env ~hash index : (unit, string) result =
| Some cache_dir -> (
let fs = Eio.Stdenv.fs env in
let path =
Eio.Path.(fs /
Filename.concat cache_dir (Fmt.str "%s%s" hash Params.index_file_ext))
Eio.Path.(
fs /
File_utils.fix_path_for_eio
(Filename.concat
cache_dir
(Fmt.str "%s%s" hash Params.index_file_ext))
)
in
let json = Index.to_json index in
try
Expand All @@ -142,6 +147,7 @@ let find_index ~env ~hash : Index.t option =
try
let path_str =
Filename.concat cache_dir (Fmt.str "%s.index" hash)
|> File_utils.fix_path_for_eio
in
let path =
Eio.Path.(fs / path_str)
Expand Down
7 changes: 7 additions & 0 deletions bin/file_utils.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
open Misc_utils
open Debug_utils

let fix_path_for_eio (s : string) =
if Sys.win32 then (
CCString.replace ~sub:"\\" ~by:"/" s
) else (
s
)

let remove_cwd_from_path (s : string) =
let pre = Params.cwd_with_trailing_sep in
match CCString.chop_prefix ~pre s with
Expand Down

0 comments on commit 1aee502

Please sign in to comment.