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 ()
210 std::string tempd =
do_getenv (
"TMPDIR");
212 #if defined (__MINGW32__) || defined (_MSC_VER)
220 #if defined (P_tmpdir)
227 if (tempd.empty () || tempd == R
"(\)")
228 tempd = R"(c:\temp)";
235 #if defined (P_tmpdir)
253 #if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && defined (OCTAVE_USE_WINDOWS_API)
254 wchar_t path[MAX_PATH+1];
255 if (SHGetFolderPathW (
nullptr, CSIDL_APPDATA | CSIDL_FLAG_DONT_VERIFY,
256 nullptr, SHGFP_TYPE_CURRENT, path) == S_OK)
262 if (cfg_dir.empty ())
274 #if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && defined (OCTAVE_USE_WINDOWS_API)
275 wchar_t path[MAX_PATH+1];
276 if (SHGetFolderPathW (
nullptr, CSIDL_APPDATA | CSIDL_FLAG_DONT_VERIFY,
277 nullptr, SHGFP_TYPE_CURRENT, path) == S_OK)
311 std::string display =
getenv (
"DISPLAY");
313 return ! display.empty ();
326 static bool initialized =
false;
364 std::size_t
len = home_dir.length ();
366 if (
len > 1 && home_dir == name.substr (0,
len)
370 retval.append (name.substr (
len));
381 std::size_t
len = s.length ();
389 #if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM)
390 if ((
len == 2 && isalpha (s[0]) && s[1] ==
':')
391 || (
len > 2 && isalpha (s[0]) && s[1] ==
':'
402 std::size_t
len = s.length ();
407 if (
len == 1 && s[0] ==
'.')
413 if (
len == 2 && s[0] ==
'.' && s[1] ==
'.')
416 if (
len > 2 && s[0] ==
'.' && s[1] ==
'.'
435 if (pos == std::string::npos)
438 return s.substr (pos+1);
446 const std::string& dot_path)
const
456 std::string current_dir = dot_path;
462 std::size_t slen = s.length ();
494 if (sep_pos == std::string::npos)
496 current_dir.append (s, i, sep_pos-i);
499 else if (sep_pos == i)
506 current_dir.append (s, i, sep_pos-i+1);
513 current_dir.pop_back ();
540 #if defined (__MINGW32__) || defined (_MSC_VER)
544 std::string drv =
do_getenv (
"HOMEDRIVE");
554 sys::password pw = sys::password::getpwuid (
sys::getuid ());
567 sys::password pw = sys::password::getpwuid (
sys::getuid ());
640 std::size_t i = path.length () - 1;
647 #if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM)
649 if (i == 1 && path[i] ==
':')
669 (*current_liboctave_error_handler) (
"%s", std::strerror (err_num));
675 (*current_liboctave_error_handler) (
"%s", s.c_str ());
charNDArray min(char d, const charNDArray &m)
bool do_rooted_relative_pathname(const std::string &s) const
static std::string base_pathname(const std::string &s)
static std::string get_host_name(void)
std::string do_base_pathname(const std::string &s) const
static std::string get_home_directory(void)
std::string do_get_host_name(void)
std::string do_polite_directory_format(const std::string &name)
static std::string get_user_config_directory(void)
static std::string getenv(const std::string &name)
static bool absolute_pathname(const std::string &s)
std::string do_getcwd(void)
std::string do_make_absolute(const std::string &s, const std::string &dot_path) const
std::string do_get_user_config_directory(void)
static std::string get_user_data_directory(void)
void do_set_program_name(const std::string &s)
std::string m_prog_invocation_name
void pathname_backup(std::string &path, int n) const
static bool rooted_relative_pathname(const std::string &s)
static bool chdir(const std::string &newdir)
static std::string make_absolute(const std::string &s, const std::string &dot_path=get_current_directory())
std::string do_get_user_name(void)
std::string do_get_home_directory(void)
static std::string get_program_invocation_name(void)
static bool have_x11_display(void)
static std::string get_current_directory(void)
std::string do_get_temp_directory(void) const
static void putenv(const std::string &name, const std::string &value)
static std::string get_user_name(void)
static std::string get_program_name(void)
std::string do_getenv(const std::string &name) const
static void cleanup_instance(void)
static std::string polite_directory_format(const std::string &name)
std::string m_current_directory
bool do_chdir(const std::string &newdir)
bool do_absolute_pathname(const std::string &s) const
std::string do_get_user_data_directory(void)
static bool instance_ok(void)
static std::string get_temp_directory(void)
static void set_program_name(const std::string &s)
bool m_follow_symbolic_links
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
std::string data_dir(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)
int chdir(const std::string &path_arg)
void putenv_wrapper(const std::string &name, const std::string &value)
static char * strsave(const char *s)
const char * octave_set_program_name_wrapper(const char *pname)
static bool is_dir_sep(char c)
static std::string dir_sep_chars
int octave_gethostname_wrapper(char *nm, size_t len)