YSTest: NativeAPI.h 源文件

YSTest PreAlpha_b700_20160611 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

NativeAPI.h
浏览该文件的文档.
1 /*
2 © 2011-2016 FrankHB.
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 #include "YModules.h"
32 #include YFM_YCLib_Platform
33 #include <ystdex/type_op.hpp> // for ystdex::make_signed_t, std::is_signed;
34 #include YFM_YBaseMacro
35
36 #ifndef YF_Platform
37 # error "Unknown platform found."
38 #endif
39
52 #if YCL_API_Has_dirent_h
53 # include <dirent.h>
54 #endif
55
56 // TODO: Test whether <fcntl.h> is available.
57 #include <fcntl.h>
58
59 #if YCL_API_Has_unistd_h
60 # include <unistd.h>
62
63 namespace platform
64 {
65 using ssize_t = ::ssize_t;
66 } // namespace platform_ex;
67 # else
68 namespace platform
69 {
70 # if YCL_Win32
71 using ssize_t = int;
72 # else
73 using ssize_t = ystdex::make_signed_t<std::size_t>;
74 # endif
75 } // namespace platform;
76
77 static_assert(std::is_signed<platform::ssize_t>(),
78 "Invalid signed size type found.");
80 #endif
81
82
83 #if YCL_DS
84 # include <nds.h>
85 # include <ystdex/base.h> // for ystdex::nonmovable;
86
87 namespace platform_ex
88 {
89
99 inline void
100 DMAFillWordsAsync(std::uint8_t chan, std::uint32_t val, void* p_dst,
101 std::uint32_t size)
102 {
103 DMA_FILL(chan) = std::uint32_t(val);
104 DMA_SRC(3) = std::uint32_t(&DMA_FILL(3));
105 DMA_DEST(3) = std::uint32_t(p_dst);
106
107 DMA_CR(3) = DMA_SRC_FIX | DMA_COPY_WORDS | size >> 2;
108 }
109
110
115 class YF_API FileSystem final
116 : private ystdex::noncopyable, private ystdex::nonmovable
117 {
118 public:
119 enum class RootKind
120 {
121 Null,
122 SD,
123 FAT
124 };
125
126 private:
127 RootKind root;
128 const char* init_dev;
129
130 public:
138 FileSystem(size_t = 16);
143 ~FileSystem();
144 };
145
146 } // namespace platform_ex;
147
148
149 #elif YCL_Win32
150
151 # ifndef UNICODE
152 # define UNICODE 1
153 # endif
154
155 # ifndef WINVER
156 # define WINVER 0x0501
158 # endif
159
160 # ifndef WIN32_LEAN_AND_MEAN
161 # define WIN32_LEAN_AND_MEAN 1
163 # endif
164
165 # ifndef NOMINMAX
166 # define NOMINMAX 1
168 # endif
169
170 # include <Windows.h>
171 # include <direct.h>
172
174
175 # undef CopyFile
177 # undef CreateHardLink
179 # undef CreateSymbolicLink
181 # undef DialogBox
183 # undef DrawText
185 # undef ExpandEnvironmentStrings
187 # undef FindWindow
189 # undef FormatMessage
191 # undef GetMessage
193 # undef GetObject
195 # undef PostMessage
197
198
199 extern "C"
200 {
201
202 # if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
203 YF_API struct ::tm* __cdecl __MINGW_NOTHROW
205 _gmtime32(const ::__time32_t*);
206 # endif
207
208 } // extern "C";
209 #endif
210
211 #if YCL_Win32 || YCL_API_POSIXFileSystem
212 # include <sys/stat.h>
213
214 namespace platform
215 {
216
218 enum class Mode
219 # if YCL_Win32
220 : unsigned short
221 # else
222 : ::mode_t
223 # endif
224 {
225 # if YCL_Win32
226 FileType = _S_IFMT,
227 Directory = _S_IFDIR,
228 Character = _S_IFCHR,
229 FIFO = _S_IFIFO,
230 Regular = _S_IFREG,
231 UserRead = _S_IREAD,
232 UserWrite = _S_IWRITE,
233 UserExecute = _S_IEXEC,
234 GroupRead = _S_IREAD >> 3,
235 GroupWrite = _S_IWRITE >> 3,
236 GroupExecute = _S_IEXEC >> 3,
237 OtherRead = _S_IREAD >> 6,
238 OtherWrite = _S_IWRITE >> 6,
239 OtherExecute = _S_IEXEC >> 6,
240 # else
241 FileType = S_IFMT,
242 Directory = S_IFDIR,
243 Character = S_IFCHR,
244 Block = S_IFBLK,
245 Regular = S_IFREG,
246 Link = S_IFLNK,
247 Socket = S_IFSOCK,
248 FIFO = S_IFIFO,
249 UserRead = S_IRUSR,
250 UserWrite = S_IWUSR,
251 UserExecute = S_IXUSR,
252 GroupRead = S_IRGRP,
253 GroupWrite = S_IWGRP,
254 GroupExecute = S_IXGRP,
255 OtherRead = S_IROTH,
256 OtherWrite = S_IWOTH,
257 OtherExecute = S_IXOTH,
258 # endif
259 UserReadWrite = UserRead | UserWrite,
260 User = UserReadWrite | UserExecute,
261 GroupReadWrite = GroupRead | GroupWrite,
262 Group = GroupReadWrite | GroupExecute,
263 OtherReadWrite = OtherRead | OtherWrite,
264 Other = OtherReadWrite | OtherExecute,
265 Read = UserRead | GroupRead | OtherRead,
266 Write = UserWrite | GroupWrite | OtherWrite,
267 Execute = UserExecute | GroupExecute | OtherExecute,
268 ReadWrite = Read | Write,
269 Access = ReadWrite | Execute,
271
272 # if !YCL_Win32
273 SetUserID = S_ISUID,
274 SetGroupID = S_ISGID,
275 # else
276 SetUserID = 0,
277 SetGroupID = 0,
278 # endif
279 # if YCL_Linux || _XOPEN_SOURCE
280 VTX = S_ISVTX,
281 # else
282 VTX = 0,
283 # endif
284 PMode = SetUserID | SetGroupID | VTX | Access,
285 All = PMode | FileType
287 };
288
290
291 DefBitmaskEnum(Mode)
293
294 yconstfn PDefH(bool, HasExtraMode, Mode m)
296 ImplRet(bool(m & ~(Mode::Access | Mode::FileType)))
298
299 } // namespace platform;
300 #endif
301
302 #if YCL_Android
303
307 extern "C"
308 {
309
314 int
315 linkat(int, const char*, int, const char*, int) ynothrow;
316
317 # ifndef UTIME_NOW
318 # define UTIME_NOW ((1L << 30) - 1L)
319 # endif
320 # ifndef UTIME_OMIT
321 # define UTIME_OMIT ((1L << 30) - 2L)
322 # endif
323
325
326 int
327 futimens(int, const ::timespec times[2]) ynothrow;
328
329 int
330 utimensat(int, const char*, const ::timespec[2], int) ynothrow;
332
333 } // extern "C";
334 #endif
335
336 #endif
337
platform::NodeCategory::Directory
platform::mode_t
::mode_t mode_t
文件模式类型。
Definition: FileIO.h:108
DefBitmaskEnum
#define DefBitmaskEnum(_tEnum)
Definition: YBaseMacro.h:475
YSLib::Execute
void Execute(GUIApplication &app, shared_ptr< Shell > p_shl)
Definition: GUIApplication.cpp:308
platform::NodeCategory::Regular
platform::NodeCategory::Block
CHRLib::CharSet::Null
空字符集。
Definition: Encoding.h:63
platform::NodeCategory::Character
platform::NodeCategory::Link
platform_ex::Windows::unsigned
YF_API unsigned
Definition: MinGW32.h:630
platform::ssize_t
ystdex::make_signed_t< std::size_t > ssize_t
Definition: NativeAPI.h:73
platform
默认平台命名空间。
Definition: Container.h:47
base.h
基类实用设施。
platform::ynothrow
const _tString &path ynothrow
Definition: YCLib/FileSystem.h:303
ystdex::size
auto size(const _tRange &c) -> decltype(c.size())
类容器访问。
Definition: range.hpp:233
platform_ex
平台扩展命名空间。
Definition: Android.h:45
ystdex::nonmovable
Definition: base.h:81
YModules.h
YSLib::IO::int
YF_API int
Definition: File.h:49
platform::ImplRet
const string &s ImplRet(s) YF_API string MakePathString(const char16_t *)
yconstfn
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:654
type_op.hpp
C++ 类型操作。
ystdex::noncopyable
不可复制对象：禁止派生类调用默认原型的复制构造函数和复制赋值操作符。
Definition: base.h:41
platform::if
if(!p) p
YF_API
#define YF_API
Definition: Platform.h:56
platform::NodeCategory::Socket
platform::NodeCategory::FIFO
platform_ex::Windows::AccessRights::All
platform::PDefH
PDefH(string, MakePathString, const char *s) ImplRet(Nonnull(s)) inline PDefH(const string &
构造适合表示路径的字符串。