diff liboctave/util/kpse.cc @ 32078:632f9b828de1

Avoid using file_stat in liboctave/util (bug #59711). * cmd-edit.cc (looks_like_filename), cmd-hist.cc (gnu_history::do_append), kpse.cc (kpse_element_dir), oct-glob.cc (glob, windows_glob), url-transfer.cc (base_url_transfer::mget_directory): Use functions "dir_exists" or "file_exists" instead of "file_stat". * kpse.cc (dir_p), oct-glob.cc (single_match_exists): Remove unused static functions.
author Markus Mützel <markus.muetzel@gmx.de>
date Sat, 06 May 2023 10:56:33 +0200
parents 21f9b34eb893
children 2e484f9f1f18
line wrap: on
line diff
--- a/liboctave/util/kpse.cc	Fri May 05 19:49:23 2023 +0200
+++ b/liboctave/util/kpse.cc	Sat May 06 10:56:33 2023 +0200
@@ -45,6 +45,7 @@
 #include "file-ops.h"
 #include "file-stat.h"
 #include "kpse.h"
+#include "lo-sysdep.h"
 #include "oct-env.h"
 #include "oct-password.h"
 #include "oct-time.h"
@@ -54,8 +55,6 @@
 #if defined (OCTAVE_USE_WINDOWS_API)
 #  define WIN32_LEAN_AND_MEAN 1
 #  include <windows.h>
-
-#  include "lo-sysdep.h"
 #endif
 
 // Define the characters which separate components of filenames and
@@ -1015,17 +1014,6 @@
   return c;
 }
 
-/* Return true if FN is a directory or a symlink to a directory,
-   false if not. */
-
-static bool
-dir_p (const std::string& fn)
-{
-  octave::sys::file_stat fs (fn);
-
-  return (fs && fs.is_dir ());
-}
-
 /* Given a path element ELT, return a the element with a trailing slash
    or an empty string if the element is not a directory.
 
@@ -1042,7 +1030,7 @@
   if (elt.empty ())
     return ret;
 
-  if (dir_p (elt))
+  if (octave::sys::dir_exists (elt))
     {
       ret = elt;