Debian Codegraph @

include/cross.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2002-2010 The DOSBox Team
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19 /* $Id: cross.h,v 1.21 2009-03-14 18:02:34 qbix79 Exp $ */
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) /* MS Visual C++ */
34 #include <direct.h>
35 #include <io.h>
36 #define LONGTYPE(a) a##i64
37 #define snprintf _snprintf
38 #define vsnprintf _vsnprintf
39 #else /* LINUX / GCC */
40 #include <dirent.h>
41 #include <unistd.h>
42 #define LONGTYPE(a) a##LL
43 #endif
44
45 #define CROSS_LEN 512 /* Maximum filename size */
46
47
48 #if defined (WIN32) || defined (OS2) /* Win 32 & OS/2*/
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 //Solaris maybe others
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 // Exclude rarely-used stuff from
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 //#include <sys/types.h> //Included above
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