-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreatefilemap.c
58 lines (48 loc) · 1.34 KB
/
createfilemap.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// createfilemap.c
//
// Time-stamp: <04/01/01 12:15:59 keuchel@lightning>
#include "celib.h"
HANDLE
XCECreateFileForMappingA(
LPCSTR fname,
DWORD dwDesiredAccess,
DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile
)
{
wchar_t wfname[MAX_PATH];
HANDLE hFile;
MultiByteToWideChar(CP_ACP, 0, fname, -1, wfname, COUNTOF(wfname));
hFile = XCECreateFileForMappingW(wfname, dwDesiredAccess, dwShareMode,
lpSecurityAttributes, dwCreationDisposition,
dwFlagsAndAttributes, hTemplateFile);
return hFile;
}
HANDLE
XCECreateFileForMappingW(
LPCWSTR wfname,
DWORD dwDesiredAccess,
DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile
)
{
HANDLE hFile;
wchar_t wpath[MAX_PATH];
wchar_t *p;
DWORD dwError = 0;
XCEFixPathW(wfname, wpath);
hFile = CreateFileForMappingW(wpath, dwDesiredAccess, dwShareMode,
lpSecurityAttributes, dwCreationDisposition,
dwFlagsAndAttributes, hTemplateFile);
if(hFile == INVALID_HANDLE_VALUE)
{
errno = _winerror2errno(dwError);
}
return hFile;
}