tangled
alpha
login
or
join now
anil.recoil.org
/
xdge
1
fork
atom
XDG library path support for OCaml via Eio capabilities
linux
macos
ocaml
xdg
1
fork
atom
overview
issues
pulls
pipelines
do not leak eio exceptiosn for find_file_in_dirs
anil.recoil.org
2 months ago
ddac0133
87ae2f64
1/1
build.yml
success
3m 12s
+7
-1
1 changed file
expand all
collapse all
unified
split
lib
xdge.ml
+7
-1
lib/xdge.ml
···
236
236
let config_dirs t = t.config_dirs
237
237
let data_dirs t = t.data_dirs
238
238
239
239
+
(* Check if an Eio exception indicates a missing file/directory *)
240
240
+
let is_not_found_error = function
241
241
+
| Eio.Io (Eio.Fs.E (Eio.Fs.Not_found _), _) -> true
242
242
+
| Eio.Io (Eio.Fs.E (Eio.Fs.Permission_denied _), _) -> true
243
243
+
| _ -> false
244
244
+
239
245
(* File search following XDG specification *)
240
246
let find_file_in_dirs dirs filename =
241
247
let rec search_dirs = function
···
246
252
(* Try to check if file exists and is readable *)
247
253
let _ = Eio.Path.stat ~follow:true file_path in
248
254
Some file_path
249
249
-
with _ ->
255
255
+
with exn when is_not_found_error exn ->
250
256
(* File is inaccessible (non-existent, permissions, etc.)
251
257
Skip and continue with next directory per XDG spec *)
252
258
search_dirs remaining_dirs)