Mercurial > hg > octave-lyh
diff liboctave/oct-glob.cc @ 10345:33b012d39dce
Convert between back and forward slashes before and after calling glob.
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Sun, 21 Feb 2010 17:46:30 +0000 |
parents | 07ebe522dac2 |
children | 479cc8a0a846 |
line wrap: on
line diff
--- a/liboctave/oct-glob.cc +++ b/liboctave/oct-glob.cc @@ -24,6 +24,7 @@ #include <config.h> #endif +#include <algorithm> #include <string> #include <fnmatch.h> @@ -78,6 +79,13 @@ { glob_t glob_info; +#if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) \ + && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM) + std::replace_if (xpat.begin (), xpat.end (), + std::bind2nd (std::equal_to<char> (), '\\'), + '/'); +#endif + int err = ::glob (xpat.c_str (), GLOB_NOSORT, 0, &glob_info); if (! err) @@ -98,7 +106,19 @@ retval.resize (k+n); for (int j = 0; j < n; j++) - retval[k++] = matches[j]; + { + std::string tmp = matches[j]; + +#if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) \ + && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM) + std::replace_if (tmp.begin (), tmp.end (), + std::bind2nd (std::equal_to<char> (), + '/'), + '\\'); +#endif + + retval[k++] = tmp; + } } globfree (&glob_info);