diff liboctave/system/file-ops.h @ 22146:ef91e43f162a

set DLL directory when loading DLLs on Windows systems (bug #48511) * file-ops.h (file_ops::dirname): New function. * oct-shlib.cc (set_dll_directory): New function. (octave_w32_shlib::octave_w32_shlib): Call file_ops::dirname to get directory part of shared library file, then use set_dll_directory to temporarily alter DLL search path. * ov-java.cc (set_dll_directory): Delete. (initialize_jvm): Don't set DLL search path for Windows systems here. That job is now handled by octave::dynamic_library.
author John W. Eaton <jwe@octave.org>
date Tue, 19 Jul 2016 12:07:34 -0400
parents aea1bf9493c0
children c5842206aaea
line wrap: on
line diff
--- a/liboctave/system/file-ops.h	Tue Jul 19 11:29:29 2016 -0400
+++ b/liboctave/system/file-ops.h	Tue Jul 19 12:07:34 2016 -0400
@@ -99,6 +99,16 @@
 
       static std::string concat (const std::string&, const std::string&);
 
+      // Return the directory part of a filename or an empty string if
+      // there is no directory component.  Does not check to see
+      // whether the file exists or is a directory.
+      static std::string dirname (const std::string& path)
+      {
+        size_t ipos = path.find_last_of (dir_sep_chars ());
+
+        return (ipos != std::string::npos) ? path.substr (0, ipos) : "";
+      }
+      
       // Return the tail member of a filename.
       static std::string tail (const std::string& path)
       {