30 #if ! defined (octave_shared_fcns_h)
31 #define octave_shared_fcns_h 1
35 #if defined (OCTAVE_USE_WINDOWS_API)
38 # include <tlhelp32.h>
42 # if defined (_MSC_VER)
44 # define pclose _pclose
48 w32_get_octave_home (
void)
54 wchar_t namebuf[MAX_PATH+1];
56 = GetModuleFileNameW (GetModuleHandle (
nullptr), namebuf, MAX_PATH);
57 if (n_size < MAX_PATH)
60 std::wstring_convert<std::codecvt_utf8<wchar_t>,
wchar_t> wchar_conv;
62 = wchar_conv.to_bytes (std::wstring (namebuf, n_size));
64 std::size_t pos = exe_name.rfind (
'\\');
66 if (pos != std::string::npos)
67 bin_dir = exe_name.substr (0, pos + 1);
72 std::size_t pos =
bin_dir.rfind (R
"(\bin\)");
74 if (pos != std::string::npos)
75 retval =
bin_dir.substr (0, pos);
86 #if (defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) \
87 && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM))
93 #if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM)
102 char *value = ::getenv (name.c_str ());
104 return value ? value :
"";
119 #if defined (OCTAVE_USE_WINDOWS_API)
121 oh = w32_get_octave_home ();
136 else if (op == oep && ! oh.empty ())
150 std::size_t
len = s.length ();
158 #if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM)
159 if ((
len == 2 && isalpha (s[0]) && s[1] ==
':')
160 || (
len > 2 && isalpha (s[0]) && s[1] ==
':'
171 std::string retval = s;
177 std::replace (retval.begin (), retval.end (),
'/',
dir_sep_char);
std::string bin_dir(void)
#define OCTAVE_EXEC_PREFIX
static std::string Voctave_home
static void set_octave_home(void)
static bool absolute_pathname(const std::string &s)
static std::string prepend_octave_exec_home(const std::string &s)
static const char dir_sep_char
static std::string Voctave_exec_home
static bool is_dir_sep(char c)
static std::string dir_sep_chars
static std::string prepend_home_dir(const std::string &hd, const std::string &s)
static std::string octave_getenv(const std::string &name)
static OCTAVE_UNUSED std::string prepend_octave_home(const std::string &s)