diff --git a/lib/xdge.ml b/lib/xdge.ml --- a/lib/xdge.ml +++ b/lib/xdge.ml @@ -236,6 +236,12 @@ let runtime_dir t = t.runtime_dir let config_dirs t = t.config_dirs let data_dirs t = t.data_dirs +(* Check if an Eio exception indicates a missing file/directory *) +let is_not_found_error = function + | Eio.Io (Eio.Fs.E (Eio.Fs.Not_found _), _) -> true + | Eio.Io (Eio.Fs.E (Eio.Fs.Permission_denied _), _) -> true + | _ -> false + (* File search following XDG specification *) let find_file_in_dirs dirs filename = let rec search_dirs = function @@ -246,7 +252,7 @@ try (* Try to check if file exists and is readable *) let _ = Eio.Path.stat ~follow:true file_path in Some file_path - with _ -> + with exn when is_not_found_error exn -> (* File is inaccessible (non-existent, permissions, etc.) Skip and continue with next directory per XDG spec *) search_dirs remaining_dirs)