Skip to content

Commit

Permalink
refs #761 fixed glob() on windows with a leading path
Browse files Browse the repository at this point in the history
  • Loading branch information
davidnich committed Apr 16, 2016
1 parent affe09c commit c083593
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
3 changes: 2 additions & 1 deletion doxygen/lang/900_release_notes.dox.tmpl
Expand Up @@ -498,7 +498,8 @@
- fixed a bug where the @ref int_type "int" type restriction would accept any data type at runtime instead of throwing a \c RUNTIME-TYPE-ERROR exception (<a href="https://github.com/qorelanguage/qore/issues/683">issue 683</a>)
- fixed bugs reporting the current method context with certain @ref Qore::HTTPClient "HTTPClient" methods that would report the @ref Qore::Socket "Socket" class instead (<a href="https://github.com/qorelanguage/qore/issues/689">issue 689</a>)
- fixed a bug handling aborted HTTP chunked transfers; now any data available for reading on a socket when a chunked transfer is aborted is read instead of having a \c SOCKET-SEND-ERROR thrown when the remote end closes the socket during the transfer (<a href="https://github.com/qorelanguage/qore/issues/691">issue 691</a>)
- fixed a bug where SSL send failures did not cause an exception to be thrown in all cases (<a href="https://github.com/qorelanguage/qore/issues/732">issue 732</a>)
- fixed a bug with socket handling where SSL send failures did not cause an exception to be thrown in all cases (<a href="https://github.com/qorelanguage/qore/issues/732">issue 732</a>)
- fixed a bug on Windows where @ref Qore::glob() returned files matched without the leading path component (<a href="https://github.com/qorelanguage/qore/issues/761">issue 761</a>)

@section qore_0811 Qore 0.8.11

Expand Down
20 changes: 18 additions & 2 deletions include/qore/intern/glob.h
Expand Up @@ -71,8 +71,16 @@ class QoreGlobWin {

// normalize the path
QoreString path(pattern);
q_normalize_path(path);

// save the original dir name
QoreString orig_dir((const char*)q_dirname(path.c_str()));
printd(0, "glob() dir: '%s'\n", orig_dir.c_str());
if (orig_dir == ".")
orig_dir.clear();
else
orig_dir.concat('\\');

q_normalize_path(path);
char* dirp = q_dirname(path.c_str());
unsigned len = strlen(dirp);
QoreString dir(dirp, len, len + 1, QCS_DEFAULT);
Expand All @@ -83,6 +91,12 @@ class QoreGlobWin {
HANDLE h = ::FindFirstFile(dir.getBuffer(), &pfd);
ON_BLOCK_EXIT(::FindClose, h);

// remove wildcard to reuse directory name for matches
if (len > 1)
dir.terminate(dir.size() - 3);
else
dir.clear();

// make regex pattern
QoreString str(q_basenameptr(path.c_str()));

Expand All @@ -105,7 +119,9 @@ class QoreGlobWin {
if (pfd.cFileName[0] == '.' && !get_dot)
continue;
if (qrn->exec(pfd.cFileName, strlen(pfd.cFileName))) {
names.push_back(pfd.cFileName);
QoreString str(orig_dir);
str.concat(pfd.cFileName);
names.push_back(str.c_str());
//printd(5, "QoreGlobWin::set(pattern='%s') dir='%s' regex='%s' %s MATCHED\n", pattern, dir.getBuffer(), str.getBuffer(), pfd.cFileName);
}
}
Expand Down

0 comments on commit c083593

Please sign in to comment.