1
0
Fork 0

First CVS upload.

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@80
This commit is contained in:
Sjoerd van der Berg 2002-07-27 13:08:48 +00:00
parent 7d1ca9bdd4
commit 42e5d0b779
158 changed files with 42940 additions and 0 deletions

1
src/platform/Makefile.am Normal file
View file

@ -0,0 +1 @@
SUBDIRS = visualc

View file

@ -0,0 +1 @@
EXTRA_DIST = dirent.c dirent.h unistd.h config.h

View file

@ -0,0 +1,5 @@
#define INLINE __forceinline
#define VERSION "0.50"
/* Euhm */

View file

@ -0,0 +1,93 @@
/*
* Implementation of the standard functions in direct.h
*
* opendir(), readdir(), closedir() and rewinddir().
*
* 06/17/2000 by Mike Haaland <mhaaland@hypertech.com>
*/
#include "dirent.h"
#ifdef WIN32
/** open the current directory and return a structure
* to be used in subsequent readdir() and closedir()
* calls.
*
* returns NULL if one error.
*/
DIR * opendir(const char *dirname) {
static DIR dir;
/* Stash the directory name */
strcpy(dir.pathName,dirname);
/* 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;
}
/** Close the current directory - return 0 if success */
int closedir(DIR *dirp) {
/* reset ourselves to the first file in the directory
*
* We just close the current handle and reset for the
* next readdir call
*/
int result = 1;
if (dirp->handle != INVALID_HANDLE_VALUE)
{
result = FindClose(dirp->handle);
dirp->handle = INVALID_HANDLE_VALUE;
}
return (result == 0) ? 1 : 0;
}
/** get the next entry in the directory */
struct dirent * readdir(DIR *dirp) {
static struct dirent d;
if (TRUE == dirp->firstTime)
{
/** Get the first entry in the directory */
dirp->handle = FindFirstFile("*.*", &dirp->findFileData);
dirp->firstTime = FALSE;
if (INVALID_HANDLE_VALUE == dirp->handle)
{
return NULL;
}
}
else
{
int result = FindNextFile(dirp->handle, &dirp->findFileData);
if (0 == result )
{
return NULL;
}
}
/* we have a valid FIND_FILE_DATA, copy the filename */
memset(&d,'\0', sizeof(struct dirent));
strcpy(d.d_name,dirp->findFileData.cFileName);
d.d_namlen = strlen(d.d_name);
return &d;
}
/** reopen the current directory */
void rewinddir(DIR *dirp) {
closedir(dirp);
dirp->firstTime = TRUE;
}
#endif

View file

@ -0,0 +1,58 @@
/*
* Defines and structures used to implement the
* functionality standard in direct.h for:
*
* opendir(), readdir(), closedir() and rewinddir().
*
* 06/17/2000 by Mike Haaland <mhaaland@hypertech.com>
*/
#ifndef _DIRENT_H_
#define _DIRENT_H_
#ifdef _MSC_VER
#ifdef __cplusplus
extern "C" {
#endif
#include <windows.h>
#include <direct.h>
#include <sys/types.h>
#if !defined(__GNUC__)
/* Convienience macros used with stat structures */
#define S_ISDIR(x) (x & _S_IFDIR)
#define S_ISREG(x) (x & _S_IFREG)
#endif
/* Structure to keep track of the current directory status */
typedef struct my_dir {
HANDLE handle;
WIN32_FIND_DATA findFileData;
BOOLEAN firstTime;
char pathName[MAX_PATH];
} DIR;
/* Standard directory name entry returned by readdir() */
struct dirent {
char d_namlen;
char d_name[MAX_PATH];
};
/* function prototypes */
int closedir(DIR *dirp);
DIR * opendir(const char *dirname);
struct dirent * readdir(DIR *dirp);
void rewinddir(DIR *dirp);
#ifdef __cplusplus
}
#endif
#endif
#endif

View file

@ -0,0 +1,10 @@
/*
* This file is part of the Mingw32 package.
*
* unistd.h maps (roughly) to io.h
*/
#ifndef __STRICT_ANSI__
#include <io.h>
#endif