26#if defined (HAVE_CONFIG_H)
40#if defined (OCTAVE_USE_WINDOWS_API)
69 int npat = pat.
numel ();
71 const char *cstr = str.c_str ();
73 for (
int i = 0; i < npat; i++)
86 int npat = pat.
numel ();
95 for (
int i = 0; i < npat; i++)
97 std::string xpat = pat(i);
101#if (defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) \
102 && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM))
103 std::replace_if (xpat.begin (), xpat.end (),
104 std::bind2nd (std::equal_to<char> (),
'\\'),
116 const char *
const *matches
130 for (
int j = 0; j < n; j++)
132 std::string tmp = matches[j];
134#if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) \
135 && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM)
136 std::replace_if (tmp.begin (), tmp.end (),
137 std::bind2nd (std::equal_to<char> (),
151 return retval.
sort ();
154#if defined (OCTAVE_USE_WINDOWS_API)
157 find_files (std::list<std::string>& dirlist,
const std::string& dir,
158 const std::string& pat, std::string& file)
162 file = file.substr (1, std::string::npos);
166 _WIN32_FIND_DATAW ffd;
167 HANDLE h_find = FindFirstFileW (wpat.c_str (), &ffd);
169 if (h_find == INVALID_HANDLE_VALUE)
181 if (found_dir.compare (
".") && found_dir.compare (
".."))
189 std::string pat_str = file.substr (0, sep_pos);
190 std::string file_str = (sep_pos != std::string::npos
191 && file.length () > sep_pos+1)
192 ? file.substr (sep_pos+1) :
"";
199 while (FindNextFileW (h_find, &ffd) != 0);
211 int npat = pat.
numel ();
213#if defined (OCTAVE_USE_WINDOWS_API)
215 std::list<std::string> dirlist;
217 for (
int i = 0; i < npat; i++)
219 std::string xpat = pat(i);
226 std::string file = (sep_pos != std::string::npos
227 && xpat.length () > sep_pos+1)
228 ? xpat.substr (sep_pos+1) :
"";
229 xpat = xpat.substr (0, sep_pos);
231 std::string dir =
"";
233 if ((sep_pos == 2 || xpat.length () == 2) && xpat[1] ==
':')
239 file = file.substr (1, std::string::npos);
243 xpat = file.substr (0, sep_pos);
244 file = (sep_pos != std::string::npos
245 && file.length () > sep_pos+1)
246 ? file.substr (sep_pos+1) :
"";
251 if (PathFileExistsW (wpat.c_str ()))
254 dirlist.push_back (dir +
257 dirlist.push_back (dir);
263 find_files (dirlist, dir, xpat, file);
277 for (
int i = 0; i < npat; i++)
279 std::string xpat = pat(i);
284 escaped.reserve (xpat.length ());
286 for (std::size_t j = 0; j < xpat.length (); j++)
288# if (defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) \
289 && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM))
295 if (xpat[j] ==
']' || xpat[j] ==
'[')
303 int len = escaped.length ();
304 if (
len >= 3 && escaped.substr (
len - 3) ==
"*.*")
305 escaped = escaped.substr (0,
len - 2);
315 const char *
const *matches
329 for (
int j = 0; j < n; j++)
331 std::string tmp = matches[j];
333 std::string unescaped;
334 unescaped.reserve (tmp.length ());
336 for (std::size_t m = 0; m < tmp.length (); m++)
338# if (defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) \
339 && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM))
346 && ++m == tmp.length ())
353 retval[k++] = unescaped;
363 return retval.
sort ();
string_vector & sort(bool make_uniq=false)
void resize(octave_idx_type n, const std::string &rfv="")
octave_idx_type numel(void) const
void * octave_create_glob_info_struct(void)
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)
char ** octave_glob_match_list(void *glob_info)
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)
std::string concat(const std::string &dir, const std::string &file)
std::string dir_sep_chars(void)
string_vector glob(const string_vector &pat)
std::string u8_from_wstring(const std::wstring &wchar_string)
bool fnmatch(const string_vector &pat, const std::string &str, int fnm_flags)
std::wstring u8_to_wstring(const std::string &utf8_string)
string_vector windows_glob(const string_vector &pat)
static bool single_match_exists(const std::string &file)