From 943b4e81d329c8f9acfcfa59003d7713c026d924 Mon Sep 17 00:00:00 2001 From: Sjoerd van der Berg Date: Thu, 28 Nov 2002 00:42:34 +0000 Subject: [PATCH] No longer change dir when doing directory searches. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@542 --- src/platform/visualc/dirent.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/platform/visualc/dirent.c b/src/platform/visualc/dirent.c index 1f8df13e..f6be7922 100644 --- a/src/platform/visualc/dirent.c +++ b/src/platform/visualc/dirent.c @@ -7,6 +7,7 @@ */ #include "dirent.h" +#include "io.h" #ifdef WIN32 @@ -22,17 +23,14 @@ DIR * opendir(const char *dirname) { /* Stash the directory name */ strcpy(dir.pathName,dirname); + strcat(dir.pathName,"*.*"); /* set the handle to invalid and set the firstTime flag */ dir.handle = INVALID_HANDLE_VALUE; dir.firstTime = TRUE; - if (strcmp(dirname, ".") == 0) { - return &dir; - } - /* Change the current directory to the one requested */ - return (SetCurrentDirectory(dir.pathName) != 0) ? &dir : NULL; + return (access(dirname,0) ? NULL : &dir); } /** Close the current directory - return 0 if success */ @@ -60,7 +58,7 @@ struct dirent * readdir(DIR *dirp) { if (TRUE == dirp->firstTime) { /** Get the first entry in the directory */ - dirp->handle = FindFirstFile("*.*", &dirp->findFileData); + dirp->handle = FindFirstFile(dirp->pathName, &dirp->findFileData); dirp->firstTime = FALSE; if (INVALID_HANDLE_VALUE == dirp->handle) {