XDG library path support for OCaml via Eio capabilities
linux macos ocaml xdg

do not leak eio exceptiosn for find_file_in_dirs

+7 -1
+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 + (* Check if an Eio exception indicates a missing file/directory *) 240 + let is_not_found_error = function 241 + | Eio.Io (Eio.Fs.E (Eio.Fs.Not_found _), _) -> true 242 + | Eio.Io (Eio.Fs.E (Eio.Fs.Permission_denied _), _) -> true 243 + | _ -> false 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 - with _ -> 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)