23 #if defined (__WIN32__) && ! defined (_POSIX_VERSION)
30 #define pclose _pclose
34 w32_get_octave_home (
void)
40 HANDLE h = CreateToolhelp32Snapshot (TH32CS_SNAPMODULE
41 #ifdef TH32CS_SNAPMODULE32
46 if (h != INVALID_HANDLE_VALUE)
48 MODULEENTRY32 mod_info;
50 ZeroMemory (&mod_info,
sizeof (mod_info));
51 mod_info.dwSize =
sizeof (mod_info);
53 if (Module32First (h, &mod_info))
57 std::string mod_name (mod_info.szModule);
59 if (mod_name.find (
"octave") != std::string::npos)
61 bin_dir = mod_info.szExePath;
63 if (bin_dir[bin_dir.length () - 1] !=
'\\')
64 bin_dir.append (1,
'\\');
69 while (Module32Next (h, &mod_info));
75 if (! bin_dir.empty ())
77 size_t pos = bin_dir.rfind (
"\\bin\\");
79 if (pos != std::string::npos)
80 retval = bin_dir.substr (0, pos);
91 #if (defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) \
92 && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM))
95 static const char dir_sep_char =
'/';
101 char *value = ::getenv (name.c_str ());
103 return value ? value :
"";
111 #if defined (__WIN32__) && ! defined (_POSIX_VERSION)
113 oh = w32_get_octave_home ();
130 if (octave_home != prefix)
134 if (s.substr (0, len) == prefix)
135 retval.replace (0, len, octave_home);
138 if (dir_sep_char !=
'/')
static std::string get_octave_home(void)
static std::string subst_octave_home(const std::string &s)
static void replace(QString &text, const QRegExp &re, const QString &after)
static const char dir_sep_char
static std::string octave_getenv(const std::string &name)