From 3d07a97939c6f677f1c14741eec359bf60fb084e Mon Sep 17 00:00:00 2001
From: Andre Maroneze <andre.maroneze@cea.fr>
Date: Mon, 9 Oct 2023 11:28:51 +0200
Subject: [PATCH] start using new Filepath functions

---
 src/kernel_services/ast_queries/file.ml            | 6 +++---
 src/kernel_services/plugin_entry_points/dynamic.ml | 2 +-
 src/kernel_services/plugin_entry_points/plugin.ml  | 4 ++--
 src/plugins/markdown-report/md_gen.ml              | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/kernel_services/ast_queries/file.ml b/src/kernel_services/ast_queries/file.ml
index ebd8cc54651..ec24f15d0b6 100644
--- a/src/kernel_services/ast_queries/file.ml
+++ b/src/kernel_services/ast_queries/file.ml
@@ -505,7 +505,7 @@ let silence_cpp_machdep_warnings cmdl =
 let build_cpp_cmd = function
   | NoCPP _ | External _ -> None
   | NeedCPP (f, cmdl, extra_for_this_file, is_gnu_like) ->
-    if not (Sys.file_exists (f :> string)) then
+    if not (Filepath.exists f) then
       Kernel.abort "source file %a does not exist"
         Filepath.Normalized.pretty f;
     let debug = Kernel.is_debug_key_enabled Kernel.dkey_parser in
@@ -602,7 +602,7 @@ let abort_with_detailed_pp_message f cpp_command =
 
 let parse_cabs cpp_command = function
   | NoCPP f ->
-    if not (Sys.file_exists (f:>string)) then
+    if not (Filepath.exists f) then
       Kernel.abort "preprocessed file %a does not exist"
         Filepath.Normalized.pretty f;
     Kernel.feedback "Parsing %a (no preprocessing)"
@@ -651,7 +651,7 @@ let parse_cabs cpp_command = function
     safe_remove_file ppf;
     (cil,(f,defs))
   | External (f,suf) ->
-    if not (Sys.file_exists (f:>string)) then
+    if not (Filepath.exists f) then
       Kernel.abort "file %a does not exist."
         Filepath.Normalized.pretty f;
     Kernel.feedback "Parsing %a (external front-end)"
diff --git a/src/kernel_services/plugin_entry_points/dynamic.ml b/src/kernel_services/plugin_entry_points/dynamic.ml
index 341b192f35c..9524edda488 100644
--- a/src/kernel_services/plugin_entry_points/dynamic.ml
+++ b/src/kernel_services/plugin_entry_points/dynamic.ml
@@ -99,7 +99,7 @@ let is_package =
 
 let is_file base ext =
   let file = base ^ ext in
-  if Sys.file_exists file then Some file else None
+  if (Filepath.exists (Filepath.Normalized.of_string file)) then Some file else None
 
 let is_object base =
   if Dynlink.is_native then is_file base ".cmxs" else
diff --git a/src/kernel_services/plugin_entry_points/plugin.ml b/src/kernel_services/plugin_entry_points/plugin.ml
index fa3be70c5d5..1e416c731f6 100644
--- a/src/kernel_services/plugin_entry_points/plugin.ml
+++ b/src/kernel_services/plugin_entry_points/plugin.ml
@@ -362,7 +362,7 @@ struct
               List.fold_left
                 (fun dummy d ->
                    let name = Datatype.Filepath.concat d s in
-                   if Sys.file_exists (name :> string)
+                   if FramacFilepath.exists name
                    then raise (Found name)
                    else dummy)
                 None
@@ -424,7 +424,7 @@ struct
       let filepath = Datatype.Filepath.concat base_dir s_basename in
       match mode with
       | `Must_exist ->
-        if Sys.file_exists (filepath :> string)
+        if FramacFilepath.exists filepath
         then filepath
         else L.abort "there is no file %s in %s directories" (filepath :> string) O.option_name
       | `Normalize_only ->
diff --git a/src/plugins/markdown-report/md_gen.ml b/src/plugins/markdown-report/md_gen.ml
index 25bce3d1966..1e94eaa7fa1 100644
--- a/src/plugins/markdown-report/md_gen.ml
+++ b/src/plugins/markdown-report/md_gen.ml
@@ -562,7 +562,7 @@ let mk_remarks is_draft =
     Parse_remarks.get_remarks (Mdr_params.Remarks.get ())
   else if is_draft then begin
     let f = Mdr_params.Output.get() in
-    if Sys.file_exists (f:>string) then begin
+    if Filepath.exists f then begin
       Mdr_params.feedback
         "Re-using pre-existing remarks in draft file %a"
         Filepath.Normalized.pretty f;
-- 
GitLab