28 # ifdef USE_STANDALONE
29 # define MEM_mallocN(size, str) ((void)str, malloc(size))
30 # define MEM_callocN(size, str) ((void)str, calloc(size, 1))
31 # define MEM_freeN(ptr) free(ptr)
36 # define WIN32_SKIP_HKEY_PROTECTION
41 # define PATH_SUFFIX "\\*"
42 # define PATH_SUFFIX_LEN 2
47 WIN32_FIND_DATAW
data;
48 char path[MAX_PATH + PATH_SUFFIX_LEN];
71 if ((GetFileAttributesW(path_16) & FILE_ATTRIBUTE_DIRECTORY) &&
72 ((path_len = strlen(path)) < (
sizeof(newd->path) - PATH_SUFFIX_LEN))) {
74 newd->handle = INVALID_HANDLE_VALUE;
75 memcpy(newd->path, path, path_len);
76 memcpy(newd->path + path_len, PATH_SUFFIX, PATH_SUFFIX_LEN + 1);
78 newd->direntry.d_ino = 0;
79 newd->direntry.d_off = 0;
80 newd->direntry.d_reclen = 0;
81 newd->direntry.d_name =
NULL;
88 static char *BLI_alloc_utf_8_from_16(
wchar_t *in16,
size_t add)
95 out8 = (
char *)
MEM_mallocN(
sizeof(
char) * (bsize +
add),
"UTF-8 String");
103 wchar_t *out16 =
NULL;
107 out16 = (
wchar_t *)
MEM_mallocN(
sizeof(
wchar_t) * (bsize +
add),
"UTF-16 String");
114 if (dp->direntry.d_name) {
116 dp->direntry.d_name =
NULL;
119 if (dp->handle == INVALID_HANDLE_VALUE) {
121 dp->handle = FindFirstFileW(path_16, &(dp->data));
123 if (dp->handle == INVALID_HANDLE_VALUE) {
127 dp->direntry.d_name = BLI_alloc_utf_8_from_16(dp->data.cFileName, 0);
129 return &dp->direntry;
131 else if (FindNextFileW(dp->handle, &(dp->data))) {
132 dp->direntry.d_name = BLI_alloc_utf_8_from_16(dp->data.cFileName, 0);
134 return &dp->direntry;
143 if (dp->direntry.d_name) {
146 if (dp->handle != INVALID_HANDLE_VALUE) {
147 FindClose(dp->handle);
void BLI_kdtree_nd_() free(KDTree *tree)
#define UNUSED_FUNCTION(x)
Compatibility-like things for windows.
struct dirent * readdir(DIR *dp)
DIR * opendir(const char *path)
Read Guarded memory(de)allocation.
void(* MEM_freeN)(void *vmemh)
void *(* MEM_mallocN)(size_t len, const char *str)
static void add(GHash *messages, MemArena *memarena, const Message *msg)
size_t count_utf_8_from_16(const wchar_t *string16)
wchar_t * alloc_utf16_from_8(const char *in8, size_t add)
int conv_utf_8_to_16(const char *in8, wchar_t *out16, size_t size16)
int conv_utf_16_to_8(const wchar_t *in16, char *out8, size_t size8)
size_t count_utf_16_from_8(const char *string8)