13 # ifdef USE_STANDALONE
14 # define MEM_mallocN(size, str) ((void)str, malloc(size))
15 # define MEM_callocN(size, str) ((void)str, calloc(size, 1))
16 # define MEM_freeN(ptr) free(ptr)
21 # define WIN32_SKIP_HKEY_PROTECTION
26 # define PATH_SUFFIX "\\*"
27 # define PATH_SUFFIX_LEN 2
32 WIN32_FIND_DATAW
data;
33 char path[MAX_PATH + PATH_SUFFIX_LEN];
56 if ((GetFileAttributesW(path_16) & FILE_ATTRIBUTE_DIRECTORY) &&
57 ((path_len = strlen(path)) < (
sizeof(newd->path) - PATH_SUFFIX_LEN))) {
59 newd->handle = INVALID_HANDLE_VALUE;
60 memcpy(newd->path, path, path_len);
61 memcpy(newd->path + path_len, PATH_SUFFIX, PATH_SUFFIX_LEN + 1);
63 newd->direntry.d_ino = 0;
64 newd->direntry.d_off = 0;
65 newd->direntry.d_reclen = 0;
66 newd->direntry.d_name =
NULL;
73 static char *BLI_alloc_utf_8_from_16(
wchar_t *in16,
size_t add)
80 out8 = (
char *)
MEM_mallocN(
sizeof(
char) * (bsize +
add),
"UTF-8 String");
88 wchar_t *out16 =
NULL;
92 out16 = (
wchar_t *)
MEM_mallocN(
sizeof(
wchar_t) * (bsize +
add),
"UTF-16 String");
99 if (dp->direntry.d_name) {
101 dp->direntry.d_name =
NULL;
104 if (dp->handle == INVALID_HANDLE_VALUE) {
106 dp->handle = FindFirstFileW(path_16, &(dp->data));
108 if (dp->handle == INVALID_HANDLE_VALUE) {
112 dp->direntry.d_name = BLI_alloc_utf_8_from_16(dp->data.cFileName, 0);
114 return &dp->direntry;
116 else if (FindNextFileW(dp->handle, &(dp->data))) {
117 dp->direntry.d_name = BLI_alloc_utf_8_from_16(dp->data.cFileName, 0);
119 return &dp->direntry;
128 if (dp->direntry.d_name) {
131 if (dp->handle != INVALID_HANDLE_VALUE) {
132 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)
bool add(void *owner, const AttributeIDRef &attribute_id, eAttrDomain domain, eCustomDataType data_type, const AttributeInit &initializer)
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)