26 #if defined (HAVE_CONFIG_H)
41 #if defined (OCTAVE_USE_WINDOWS_API)
60 int npat = pat.
numel ();
62 const char *cstr = str.c_str ();
64 for (
int i = 0; i < npat; i++)
77 int npat = pat.
numel ();
86 for (
int i = 0; i < npat; i++)
88 std::string xpat = pat(i);
92 #if (defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) \
93 && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM))
94 std::replace (xpat.begin (), xpat.end (),
'\\',
'/');
105 const char *
const *matches
119 for (
int j = 0; j <
n; j++)
121 std::string tmp = matches[j];
123 #if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) \
124 && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM)
125 std::replace (tmp.begin (), tmp.end (),
'/',
'\\');
137 return retval.
sort ();
140 #if defined (OCTAVE_USE_WINDOWS_API)
143 find_files (std::list<std::string>& dirlist,
const std::string& dir,
144 const std::string& pat, std::string& file)
147 bool is_file_empty = file.
empty ();
149 file = file.substr (1, std::string::npos);
151 bool is_trailing_file_sep = ! is_file_empty && file.empty ();
153 if (! pat.compare (
".") || ! pat.compare (
".."))
160 std::string pat_str = file.substr (0, sep_pos);
161 std::string file_str = (sep_pos != std::string::npos)
162 ? file.substr (sep_pos) :
"";
165 if (pat_str.empty ())
167 if (is_trailing_file_sep)
181 _WIN32_FIND_DATAW ffd;
182 HANDLE h_find = FindFirstFileW (wpat.c_str (), &ffd);
184 if (h_find == INVALID_HANDLE_VALUE)
193 if (! (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
194 && (! file.empty () || is_trailing_file_sep))
202 if (found_dir.compare (
".") && found_dir.compare (
".."))
204 if (is_trailing_file_sep)
214 std::string pat_str = file.substr (0, sep_pos);
215 std::string file_str = (sep_pos != std::string::npos)
216 ? file.substr (sep_pos) :
"";
223 while (FindNextFileW (h_find, &ffd) != 0);
235 int npat = pat.
numel ();
237 #if defined (OCTAVE_USE_WINDOWS_API)
239 std::list<std::string> dirlist;
241 for (
int i = 0; i < npat; i++)
243 std::string xpat = pat(i);
247 std::string dir =
"";
254 if (sep_pos == 0 && xpat.length () > 1
259 if (sep_pos != std::string::npos)
262 if (sep_pos != std::string::npos)
264 dir = xpat.substr(0, sep_pos);
265 xpat = xpat.substr (sep_pos+1);
270 std::string file = (sep_pos != std::string::npos)
271 ? xpat.substr (sep_pos) :
"";
272 xpat = xpat.substr (0, sep_pos);
274 if ((sep_pos == 2 || xpat.length () == 2) && xpat[1] ==
':')
280 file = file.substr (1, std::string::npos);
284 xpat = file.substr (0, sep_pos);
285 file = (sep_pos != std::string::npos)
286 ? file.substr (sep_pos) :
"";
291 if (PathFileExistsW (wpat.c_str ()))
294 dirlist.push_back (dir +
297 dirlist.push_back (dir);
303 find_files (dirlist, dir, xpat, file);
317 for (
int i = 0; i < npat; i++)
319 std::string xpat = pat(i);
324 escaped.reserve (xpat.length ());
326 for (std::size_t j = 0; j < xpat.length (); j++)
328 # if (defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) \
329 && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM))
335 if (xpat[j] ==
']' || xpat[j] ==
'[')
343 int len = escaped.length ();
344 if (
len >= 3 && escaped.substr (
len - 3) ==
"*.*")
345 escaped = escaped.substr (0,
len - 2);
355 const char *
const *matches
369 for (
int j = 0; j <
n; j++)
371 std::string tmp = matches[j];
373 std::string unescaped;
374 unescaped.reserve (tmp.length ());
376 for (std::size_t
m = 0;
m < tmp.length ();
m++)
378 # if (defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) \
379 && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM))
386 && ++
m == tmp.length ())
393 retval[k++] = unescaped;
403 return retval.
sort ();
406 OCTAVE_END_NAMESPACE(sys)
407 OCTAVE_END_NAMESPACE(
octave)
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
string_vector & sort(bool make_uniq=false)
void resize(octave_idx_type n, const std::string &rfv="")
octave_idx_type numel() const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
std::string dir_sep_chars()
int octave_fnm_nomatch_wrapper(void)
int octave_glob_nosort_wrapper(void)
void octave_destroy_glob_info_struct(void *glob_info)
void octave_globfree_wrapper(void *glob_info)
void * octave_create_glob_info_struct(void)
int octave_glob_num_matches(void *glob_info)
int octave_glob_wrapper(const char *pattern, int flags, void *glob_info)
int octave_fnmatch_wrapper(const char *pattern, const char *name, int flags)
char ** octave_glob_match_list(void *glob_info)
std::string u8_from_wstring(const std::wstring &wchar_string)
bool file_exists(const std::string &filename, bool is_dir)
std::wstring u8_to_wstring(const std::string &utf8_string)
string_vector windows_glob(const string_vector &pat)
bool fnmatch(const string_vector &pat, const std::string &str, int fnm_flags)
string_vector glob(const string_vector &pat)