42#if defined (HAVE_CONFIG_H)
63#if defined (OCTAVE_USE_WINDOWS_API)
73 : m_follow_symbolic_links (true), m_verbatim_pwd (true),
74 m_current_directory (), m_prog_name (), m_prog_invocation_name (),
75 m_user_name (), m_host_name ()
212#if defined (__MINGW32__) || defined (_MSC_VER)
219#if defined (P_tmpdir)
226 if (tempd.empty () || tempd == R
"(\)")
227 tempd = R"(c:\temp)";
233#if defined (P_tmpdir)
251#if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && defined (OCTAVE_USE_WINDOWS_API)
252 wchar_t path[MAX_PATH+1];
253 if (SHGetFolderPathW (
nullptr, CSIDL_APPDATA | CSIDL_FLAG_DONT_VERIFY,
254 nullptr, SHGFP_TYPE_CURRENT,
path) == S_OK)
260 if (cfg_dir.empty ())
272#if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && defined (OCTAVE_USE_WINDOWS_API)
273 wchar_t path[MAX_PATH+1];
274 if (SHGetFolderPathW (
nullptr, CSIDL_APPDATA | CSIDL_FLAG_DONT_VERIFY,
275 nullptr, SHGFP_TYPE_CURRENT,
path) == S_OK)
309 std::string display =
getenv (
"DISPLAY");
311 return ! display.empty ();
324 static bool initialized =
false;
362 std::size_t
len = home_dir.length ();
364 if (
len > 1 && home_dir ==
name.substr (0,
len)
368 retval.append (
name.substr (
len));
379 std::size_t
len = s.length ();
387#if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM)
388 if ((
len == 2 && isalpha (s[0]) && s[1] ==
':')
389 || (
len > 2 && isalpha (s[0]) && s[1] ==
':'
400 std::size_t
len = s.length ();
405 if (
len == 1 && s[0] ==
'.')
411 if (
len == 2 && s[0] ==
'.' && s[1] ==
'.')
414 if (
len > 2 && s[0] ==
'.' && s[1] ==
'.'
433 if (pos == std::string::npos)
436 return s.substr (pos+1);
444 const std::string& dot_path)
const
454 std::string current_dir = dot_path;
460 std::size_t slen = s.length ();
492 if (sep_pos == std::string::npos)
494 current_dir.append (s, i, sep_pos-i);
497 else if (sep_pos == i)
504 current_dir.append (s, i, sep_pos-i+1);
511 current_dir.pop_back ();
538#if defined (__MINGW32__) || defined (_MSC_VER)
542 std::string drv =
do_getenv (
"HOMEDRIVE");
638 std::size_t i =
path.length () - 1;
645#if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM)
647 if (i == 1 &&
path[i] ==
':')
667 (*current_liboctave_error_handler) (
"%s", std::strerror (err_num));
673 (*current_liboctave_error_handler) (
"%s", s.c_str ());
charNDArray min(char d, const charNDArray &m)
static std::string get_temp_directory(void)
static std::string get_host_name(void)
static bool rooted_relative_pathname(const std::string &s)
std::string do_get_temp_directory(void) const
static bool have_x11_display(void)
static std::string base_pathname(const std::string &s)
bool do_rooted_relative_pathname(const std::string &s) const
std::string m_current_directory
static std::string get_user_data_directory(void)
std::string do_base_pathname(const std::string &s) const
static std::string get_program_invocation_name(void)
void do_set_program_name(const std::string &s)
std::string do_get_home_directory(void)
static void cleanup_instance(void)
std::string m_prog_invocation_name
std::string do_get_host_name(void)
static std::string getenv(const std::string &name)
static bool instance_ok(void)
static void set_program_name(const std::string &s)
static std::string get_home_directory(void)
std::string do_get_user_config_directory(void)
bool m_follow_symbolic_links
std::string do_get_user_data_directory(void)
std::string do_make_absolute(const std::string &s, const std::string &dot_path) const
static std::string polite_directory_format(const std::string &name)
std::string do_polite_directory_format(const std::string &name)
static void putenv(const std::string &name, const std::string &value)
static bool absolute_pathname(const std::string &s)
std::string do_get_user_name(void)
static std::string get_user_config_directory(void)
bool do_chdir(const std::string &newdir)
std::string do_getcwd(void)
static std::string make_absolute(const std::string &s, const std::string &dot_path=get_current_directory())
static std::string get_program_name(void)
static std::string get_current_directory(void)
static bool chdir(const std::string &newdir)
bool do_absolute_pathname(const std::string &s) const
std::string do_getenv(const std::string &name) const
static std::string get_user_name(void)
void pathname_backup(std::string &path, int n) const
static password getpwuid(uid_t uid)
std::string dir(void) const
std::string name(void) const
std::string data_dir(void)
std::string dir_sep_chars(void)
std::string dir_sep_str(void)
std::string u8_from_wstring(const std::wstring &wchar_string)
std::string getenv_wrapper(const std::string &name)
void putenv_wrapper(const std::string &name, const std::string &value)
int chdir(const std::string &path_arg)
char * strsave(const char *s)
const char * octave_set_program_name_wrapper(const char *pname)
int octave_gethostname_wrapper(char *nm, size_t len)