win: remove broken Unicode variant of opendir

This commit is contained in:
David Hrdlička
2022-05-24 23:10:31 +02:00
parent 91a9df2131
commit 5a2aa70dd5
2 changed files with 4 additions and 41 deletions

View File

@@ -60,11 +60,7 @@ typedef struct {
/* Function prototypes. */
#ifdef UNICODE
extern DIR *opendirw(const wchar_t *);
#else
extern DIR *opendir(const char *);
#endif
extern struct dirent *readdir(DIR *);
extern long telldir(DIR *);
extern void seekdir(DIR *, long);

View File

@@ -28,26 +28,15 @@
#include <86box/plat_dir.h>
#ifdef UNICODE
# define SUFFIX L"\\*"
# define FINDATA struct _wfinddata_t
# define FINDFIRST _wfindfirst
# define FINDNEXT _wfindnext
#else
# define SUFFIX "\\*"
# define FINDATA struct _finddata_t
# define FINDFIRST _findfirst
# define FINDNEXT _findnext
#endif
#define SUFFIX "\\*"
#define FINDATA struct _finddata_t
#define FINDFIRST _findfirst
#define FINDNEXT _findnext
/* Open a directory. */
DIR *
#ifdef UNICODE
opendirw(const wchar_t *name)
#else
opendir(const char *name)
#endif
{
DIR *p;
@@ -69,20 +58,11 @@ opendir(const char *name)
memset(p->dta, 0x00, sizeof(struct _finddata_t));
/* Add search filespec. */
#ifdef UNICODE
wcscpy(p->dir, name);
wcscat(p->dir, SUFFIX);
#else
strcpy(p->dir, name);
strcat(p->dir, SUFFIX);
#endif
/* Special case: flag if we are in the root directory. */
#ifdef UNICODE
if (wcslen(p->dir) == 3)
#else
if (strlen(p->dir) == 3)
#endif
p->flags |= DIR_F_ISROOT;
/* Start the searching by doing a FindFirst. */
@@ -136,31 +116,18 @@ readdir(DIR *p)
p->dent.d_off = p->offset++;
switch(p->offset) {
case 1: /* . */
#ifdef UNICODE
wcsncpy(p->dent.d_name, L".", MAXNAMLEN+1);
#else
strncpy(p->dent.d_name, ".", MAXNAMLEN+1);
#endif
p->dent.d_reclen = 1;
break;
case 2: /* .. */
#ifdef UNICODE
wcsncpy(p->dent.d_name, L"..", MAXNAMLEN+1);
#else
strncpy(p->dent.d_name, "..", MAXNAMLEN+1);
#endif
p->dent.d_reclen = 2;
break;
default: /* regular entry. */
#ifdef UNICODE
wcsncpy(p->dent.d_name, ffp->name, MAXNAMLEN+1);
p->dent.d_reclen = (char)wcslen(p->dent.d_name);
#else
strncpy(p->dent.d_name, ffp->name, MAXNAMLEN+1);
p->dent.d_reclen = (char)strlen(p->dent.d_name);
#endif
}
/* Read next entry. */