16# define MEM_mallocN(size, str) ((void)str, malloc(size))
17# define MEM_callocN(size, str) ((void)str, calloc(size, 1))
18# define MEM_freeN(ptr) free(ptr)
23# define WIN32_SKIP_HKEY_PROTECTION
28# define PATH_SUFFIX "\\*"
29# define PATH_SUFFIX_LEN 2
34 WIN32_FIND_DATAW
data;
35 char path[MAX_PATH + PATH_SUFFIX_LEN];
58 if ((GetFileAttributesW(path_16) & FILE_ATTRIBUTE_DIRECTORY) &&
59 ((path_len = strlen(path)) < (
sizeof(newd->path) - PATH_SUFFIX_LEN)))
62 newd->handle = INVALID_HANDLE_VALUE;
63 memcpy(newd->path, path, path_len);
64 memcpy(newd->path + path_len,
PATH_SUFFIX, PATH_SUFFIX_LEN + 1);
66 newd->direntry.d_ino = 0;
67 newd->direntry.d_off = 0;
68 newd->direntry.d_reclen = 0;
69 newd->direntry.d_name =
NULL;
76static char *BLI_alloc_utf_8_from_16(
wchar_t *in16,
size_t add)
83 out8 = (
char *)
MEM_mallocN(
sizeof(
char) * (bsize +
add),
"UTF-8 String");
91 wchar_t *out16 =
NULL;
95 out16 = (
wchar_t *)
MEM_mallocN(
sizeof(
wchar_t) * (bsize +
add),
"UTF-16 String");
102 if (dp->direntry.d_name) {
104 dp->direntry.d_name =
NULL;
107 if (dp->handle == INVALID_HANDLE_VALUE) {
109 dp->handle = FindFirstFileW(path_16, &(dp->data));
111 if (dp->handle == INVALID_HANDLE_VALUE) {
115 dp->direntry.d_name = BLI_alloc_utf_8_from_16(dp->data.cFileName, 0);
117 return &dp->direntry;
119 else if (FindNextFileW(dp->handle, &(dp->data))) {
120 dp->direntry.d_name = BLI_alloc_utf_8_from_16(dp->data.cFileName, 0);
122 return &dp->direntry;
131 if (dp->direntry.d_name) {
134 if (dp->handle != INVALID_HANDLE_VALUE) {
135 FindClose(dp->handle);
void BLI_kdtree_nd_ free(KDTree *tree)
#define PATH_SUFFIX(path_literal, path_literal_max, sep, suffix, expect_result, expect_path)
#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_mallocN)(size_t len, const char *str)
void MEM_freeN(void *vmemh)
static void add(blender::Map< std::string, std::string > &messages, Message &msg)
wchar_t * alloc_utf16_from_8(const char *in8, size_t add)
size_t count_utf_8_from_16(const wchar_t *string16)
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)