| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
#ifndef DOSBOX_CROSS_H |
| 22 |
#define DOSBOX_CROSS_H |
| 23 |
|
| 24 |
#ifndef DOSBOX_DOSBOX_H |
| 25 |
#include "dosbox.h" |
| 26 |
#endif |
| 27 |
|
| 28 |
#include <stdio.h> |
| 29 |
#include <sys/stat.h> |
| 30 |
#include <sys/types.h> |
| 31 |
#include <string> |
| 32 |
|
| 33 |
#if defined (_MSC_VER) |
| 34 |
#include <direct.h> |
| 35 |
#include <io.h> |
| 36 |
#define LONGTYPE(a) a##i64 |
| 37 |
#define snprintf _snprintf |
| 38 |
#define vsnprintf _vsnprintf |
| 39 |
#else |
| 40 |
#include <dirent.h> |
| 41 |
#include <unistd.h> |
| 42 |
#define LONGTYPE(a) a##LL |
| 43 |
#endif |
| 44 |
|
| 45 |
#define CROSS_LEN 512 |
| 46 |
|
| 47 |
|
| 48 |
#if defined (WIN32) || defined (OS2) |
| 49 |
#define CROSS_FILENAME(blah) |
| 50 |
#define CROSS_FILESPLIT '\\' |
| 51 |
#define F_OK 0 |
| 52 |
#else |
| 53 |
#define CROSS_FILENAME(blah) strreplace(blah,'\\','/') |
| 54 |
#define CROSS_FILESPLIT '/' |
| 55 |
#endif |
| 56 |
|
| 57 |
#define CROSS_NONE 0 |
| 58 |
#define CROSS_FILE 1 |
| 59 |
#define CROSS_DIR 2 |
| 60 |
#if defined (WIN32) |
| 61 |
#define ftruncate(blah,blah2) chsize(blah,blah2) |
| 62 |
#endif |
| 63 |
|
| 64 |
|
| 65 |
#if defined (DB_HAVE_NO_POWF) |
| 66 |
#include <math.h> |
| 67 |
static inline float powf (float x, float y) { return (float) pow (x,y); } |
| 68 |
#endif |
| 69 |
|
| 70 |
class Cross { |
| 71 |
public: |
| 72 |
static void GetPlatformConfigDir(std::string& in); |
| 73 |
static void GetPlatformConfigName(std::string& in); |
| 74 |
static void CreatePlatformConfigDir(std::string& in); |
| 75 |
static void ResolveHomedir(std::string & temp_line); |
| 76 |
static void CreateDir(std::string const& temp); |
| 77 |
}; |
| 78 |
|
| 79 |
|
| 80 |
#if defined (WIN32) |
| 81 |
|
| 82 |
#define WIN32_LEAN_AND_MEAN |
| 83 |
#include <windows.h> |
| 84 |
|
| 85 |
typedef struct dir_struct { |
| 86 |
HANDLE handle; |
| 87 |
char base_path[MAX_PATH+4]; |
| 88 |
WIN32_FIND_DATA search_data; |
| 89 |
} dir_information; |
| 90 |
|
| 91 |
#else |
| 92 |
|
| 93 |
|
| 94 |
#include <dirent.h> |
| 95 |
|
| 96 |
typedef struct dir_struct { |
| 97 |
DIR* dir; |
| 98 |
char base_path[CROSS_LEN]; |
| 99 |
} dir_information; |
| 100 |
|
| 101 |
#endif |
| 102 |
|
| 103 |
dir_information* open_directory(const char* dirname); |
| 104 |
bool read_directory_first(dir_information* dirp, char* entry_name, bool& is_directory); |
| 105 |
bool read_directory_next(dir_information* dirp, char* entry_name, bool& is_directory); |
| 106 |
void close_directory(dir_information* dirp); |
| 107 |
|
| 108 |
FILE *fopen_wrap(const char *path, const char *mode); |
| 109 |
#endif |