YSTest  PreAlpha_b400_20130424
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
NativeAPI.h
浏览该文件的文档.
1 /*
2  Copyright by FrankHB 2011 - 2013.
3 
4  This file is part of the YSLib project, and may only be used,
5  modified, and distributed under the terms of the YSLib project
6  license, LICENSE.TXT. By continuing to use, modify, or distribute
7  this file you indicate that you have read the license and
8  understand and accept it fully.
9 */
10 
28 #ifndef YCL_INC_NATIVEAPI_H_
29 #define YCL_INC_NATIVEAPI_H_ 1
30 
31 //平台定义。
32 #include "Platform.h"
33 
34 #ifndef YCL_PLATFORM
35 # error Unknown platform!
36 #endif
37 
38 #define YCL_YCOMMON_H <ycommon.h>
39 #define YSL_YSBUILD_H <ysbuild.h>
40 
53 #ifdef YCL_API_USE_UNISTD
54 #include <unistd.h>
55 #endif
56 
57 #ifdef YCL_API_USE_SYS_DIR
58 #include <sys/dir.h>
59 #endif
60 
61 
62 #if YCL_DS
63 
64 #include <nds.h>
65 #include <fat.h>
66 //包含 PALib 。
67 //#include <PA9.h>
68 
69 #ifdef USE_EFS
70 //包含 EFSLib 。
71 #include "efs_lib.h"
72 #endif
73 
74 namespace platform_ex
75 {
76 
81 inline bool
82 IsDirectory(const ::dirent& d)
83 {
84  return d.d_type & DT_DIR;
85 }
86 
87 } // namespace platform_ex;
88 
89 
90 #elif defined(YCL_PLATFORM_MINGW32)
91 
92 #ifndef UNICODE
93 # define UNICODE 1
94 #endif
95 
96 #include <Windows.h>
97 #include <Windowsx.h>
98 #include <stdint.h>
99 #include <stdio.h>
100 #include <stdlib.h>
101 #include <string.h>
102 #include <time.h>
103 #include <sys/stat.h>
104 
110 #undef DialogBox
111 
117 #undef DrawText
118 
124 #undef FindWindow
125 
131 #undef GetObject
132 
138 #undef PostMessage
139 
140 
141 #define NAME_MAX 256
142 
143 #define S_IFIFO _S_IFIFO
144 
145 #define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
146 #define S_IRGRP 0
147 #define S_IWGRP 0
148 #define S_IXGRP 0
149 #define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
150 #define S_IROTH 0
151 #define S_IWOTH 0
152 #define S_IXOTH 0
153 
154 
159 namespace platform_replace
160 {
161 
167 inline int
168 makedir(char const* dir, mode_t)
169 {
170  return ::mkdir(dir);
171 }
172 
173 } // namespace platform_replace;
174 
175 
176 extern "C"
177 {
178 
179 typedef struct dirent
180 {
181  long d_ino;
182  off_t d_off;
183  unsigned short d_reclen;
184  char d_name[NAME_MAX + 1];
189  ::LPWIN32_FIND_DATAW lpWinDir;
190 } dirent;
191 
192 
193 typedef struct DIR
194 {
199  char Name[NAME_MAX];
204  ::HANDLE hNode;
209  ::WIN32_FIND_DATAW WinDir;
214  dirent POSIXDir;
215 } DIR;
216 
217 
218 YF_API DIR*
219 opendir(const char*);
220 
221 YF_API dirent*
222 readdir(DIR*);
223 
224 YF_API void
225 rewinddir(DIR*);
226 
227 YF_API int
228 closedir(DIR*);
229 
236 #define mkdir platform_replace::makedir
237 
238 } // extern "C";
239 
240 
241 namespace platform_ex
242 {
243 
248 inline bool
249 IsDirectory(const ::WIN32_FIND_DATAA& d)
250 {
251  return d.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
252 }
257 inline bool
258 IsDirectory(const ::WIN32_FIND_DATAW& d)
259 {
260  return d.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
261 }
266 inline bool
267 IsDirectory(const ::dirent& d)
268 {
269  return d.lpWinDir && IsDirectory(*d.lpWinDir);
270 }
275 inline bool
276 IsDirectory(const ::DIR& d)
277 {
278  return IsDirectory(d.WinDir);
279 }
280 
281 } // namespace platform_ex;
282 
283 #endif
284 
285 #endif
286