This repository was archived by the owner on Dec 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.c
More file actions
61 lines (57 loc) · 1.39 KB
/
util.c
File metadata and controls
61 lines (57 loc) · 1.39 KB
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
59
60
61
#include "stdafx.h"
extern _Bool isDirFileFullPermission(const wchar_t* str, unsigned int* result) {
struct _stat info;
*result = _wstat64i32(str, &info);
if (!(info.st_mode & S_IREAD))
return 0;
else if (!(info.st_mode & S_IWRITE))
return 0;
else if (info.st_nlink == 1 && info.st_mode & S_IFREG)
return 1;
else if (!(info.st_mode & S_IEXEC))
return 0;
else
return 1;
}
extern HMODULE GetCurrentModule() { // NB: XP+ solution!
HMODULE hModule = NULL;
GetModuleHandleEx(
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
(LPCTSTR)GetCurrentModule,
&hModule);
return hModule;
}
extern void strcatW(wchar_t *dest, size_t len, const wchar_t *src) {
size_t i = 0;
size_t add = 0;
while (i < len) {
if (add) {
goto wcsAppend;
}
else if (dest[i] == 0) {
wcsAppend:
(wchar_t)dest[i] = src[add];
if (!src[add])
break;
add++;
}
i++;
}
}
extern void strcatA(char *dest, size_t len, const char *src) {
size_t i = 0;
size_t add = 0;
while (i < len) {
if (add) {
goto strAppend;
}
else if (dest[i] == 0) {
strAppend:
(char)dest[i] = src[add];
if (!src[add])
break;
add++;
}
i++;
}
}