Mercurial > octave
changeset 21881:aea1bf9493c0
* file-ops.h, file-ops.cc (file_ops::file_ops): Now protected.
New arg to specify device separator character.
(file_ops::m_dev_sep_char): New data member.
(file_ops::dev_sep_char, file_ops::is_dev_sep): New functions.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 12 Jun 2016 11:15:28 -0400 |
parents | a6952c880cec |
children | d8104206e8a9 |
files | liboctave/system/file-ops.cc liboctave/system/file-ops.h |
diffstat | 2 files changed, 30 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/system/file-ops.cc Sun Jun 12 21:37:49 2016 -0700 +++ b/liboctave/system/file-ops.cc Sun Jun 12 11:15:28 2016 -0400 @@ -70,9 +70,11 @@ if (! instance) { #if (defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM)) + char system_dev_sep_char = ':'; char system_dir_sep_char = '\\'; std::string system_dir_sep_str = "\\"; #else + char system_dev_sep_char = 0; char system_dir_sep_char = '/'; std::string system_dir_sep_str = "/"; #endif @@ -82,8 +84,8 @@ std::string system_dir_sep_chars = system_dir_sep_str; #endif - instance = new file_ops (system_dir_sep_char, system_dir_sep_str, - system_dir_sep_chars); + instance = new file_ops (system_dev_sep_char, system_dir_sep_char, + system_dir_sep_str, system_dir_sep_chars); if (instance) singleton_cleanup_list::add (cleanup_instance); @@ -281,6 +283,16 @@ return dirname; } + bool + octave::sys::file_ops::is_dev_sep (char c) + { +#if (defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM)) + return c == dev_sep_char (); +#else + return false; +#endif + } + // If NAME has a leading ~ or ~user, Unix-style, expand it to the // user's home directory. If no ~, or no <pwd.h>, just return NAME.
--- a/liboctave/system/file-ops.h Sun Jun 12 21:37:49 2016 -0700 +++ b/liboctave/system/file-ops.h Sun Jun 12 11:15:28 2016 -0400 @@ -39,18 +39,22 @@ OCTAVE_API file_ops { - public: + protected: // Use a singleton class for dir_sep data members instead of just // making them static members of the file_ops class so that we // can ensure proper initialization. - file_ops (char dir_sep_char_arg = 0, + file_ops (char dev_sep_char_arg = 0, char dir_sep_char_arg = 0, const std::string& dir_sep_str_arg = std::string ("/"), const std::string& dir_sep_chars_arg = std::string ("/")) - : m_dir_sep_char (dir_sep_char_arg), m_dir_sep_str (dir_sep_str_arg), + : m_dev_sep_char (dev_sep_char_arg), + m_dir_sep_char (dir_sep_char_arg), + m_dir_sep_str (dir_sep_str_arg), m_dir_sep_chars (dir_sep_chars_arg) { } + public: + typedef std::string (*tilde_expansion_hook) (const std::string&); static tilde_expansion_hook tilde_expansion_preexpansion_hook; @@ -61,6 +65,13 @@ static string_vector tilde_additional_suffixes; + static char dev_sep_char (void) + { + return instance_ok () ? instance->m_dev_sep_char : 0; + } + + static bool is_dev_sep (char c); + static char dir_sep_char (void) { return instance_ok () ? instance->m_dir_sep_char : 0; @@ -118,6 +129,8 @@ static bool instance_ok (void); + char m_dev_sep_char; + char m_dir_sep_char; std::string m_dir_sep_str; std::string m_dir_sep_chars;