Blender  V3.3
storage.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <sys/types.h>
13 
14 #include <sys/stat.h>
15 
16 #if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__HAIKU__)
17 /* Other modern unix OS's should probably use this also. */
18 # include <sys/statvfs.h>
19 # define USE_STATFS_STATVFS
20 #endif
21 
22 #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || \
23  defined(__DragonFly__)
24 /* For statfs */
25 # include <sys/mount.h>
26 # include <sys/param.h>
27 #endif
28 
29 #if defined(__linux__) || defined(__hpux) || defined(__GNU__) || defined(__GLIBC__)
30 # include <sys/vfs.h>
31 #endif
32 
33 #include <fcntl.h>
34 #include <string.h> /* `strcpy` etc. */
35 
36 #ifdef WIN32
37 # include "BLI_string_utf8.h"
38 # include "BLI_winstuff.h"
39 # include "utfconv.h"
40 # include <ShObjIdl.h>
41 # include <direct.h>
42 # include <io.h>
43 # include <stdbool.h>
44 #else
45 # include <pwd.h>
46 # include <sys/ioctl.h>
47 # include <unistd.h>
48 #endif
49 
50 /* lib includes */
51 #include "MEM_guardedalloc.h"
52 
53 #include "BLI_fileops.h"
54 #include "BLI_linklist.h"
55 #include "BLI_path_util.h"
56 #include "BLI_string.h"
57 #include "BLI_utildefines.h"
58 
59 char *BLI_current_working_dir(char *dir, const size_t maxncpy)
60 {
61 #if defined(WIN32)
62  wchar_t path[MAX_PATH];
63  if (_wgetcwd(path, MAX_PATH)) {
64  if (BLI_strncpy_wchar_as_utf8(dir, path, maxncpy) != maxncpy) {
65  return dir;
66  }
67  }
68  return NULL;
69 #else
70  const char *pwd = BLI_getenv("PWD");
71  if (pwd) {
72  size_t srclen = BLI_strnlen(pwd, maxncpy);
73  if (srclen != maxncpy) {
74  memcpy(dir, pwd, srclen + 1);
75  return dir;
76  }
77  return NULL;
78  }
79  return getcwd(dir, maxncpy);
80 #endif
81 }
82 
83 double BLI_dir_free_space(const char *dir)
84 {
85 #ifdef WIN32
86  DWORD sectorspc, bytesps, freec, clusters;
87  char tmp[4];
88 
89  tmp[0] = '\\';
90  tmp[1] = 0; /* Just a fail-safe. */
91  if (ELEM(dir[0], '/', '\\')) {
92  tmp[0] = '\\';
93  tmp[1] = 0;
94  }
95  else if (dir[1] == ':') {
96  tmp[0] = dir[0];
97  tmp[1] = ':';
98  tmp[2] = '\\';
99  tmp[3] = 0;
100  }
101 
102  GetDiskFreeSpace(tmp, &sectorspc, &bytesps, &freec, &clusters);
103 
104  return (double)(freec * bytesps * sectorspc);
105 #else
106 
107 # ifdef USE_STATFS_STATVFS
108  struct statvfs disk;
109 # else
110  struct statfs disk;
111 # endif
112 
113  char name[FILE_MAXDIR], *slash;
114  int len = strlen(dir);
115 
116  if (len >= FILE_MAXDIR) {
117  /* path too long */
118  return -1;
119  }
120 
121  strcpy(name, dir);
122 
123  if (len) {
124  slash = strrchr(name, '/');
125  if (slash) {
126  slash[1] = 0;
127  }
128  }
129  else {
130  strcpy(name, "/");
131  }
132 
133 # if defined(USE_STATFS_STATVFS)
134  if (statvfs(name, &disk)) {
135  return -1;
136  }
137 # elif defined(USE_STATFS_4ARGS)
138  if (statfs(name, &disk, sizeof(struct statfs), 0)) {
139  return -1;
140  }
141 # else
142  if (statfs(name, &disk)) {
143  return -1;
144  }
145 # endif
146 
147  return (((double)disk.f_bsize) * ((double)disk.f_bfree));
148 #endif
149 }
150 
151 int64_t BLI_ftell(FILE *stream)
152 {
153 #ifdef WIN32
154  return _ftelli64(stream);
155 #else
156  return ftell(stream);
157 #endif
158 }
159 
160 int BLI_fseek(FILE *stream, int64_t offset, int whence)
161 {
162 #ifdef WIN32
163  return _fseeki64(stream, offset, whence);
164 #else
165  return fseek(stream, offset, whence);
166 #endif
167 }
168 
169 int64_t BLI_lseek(int fd, int64_t offset, int whence)
170 {
171 #ifdef WIN32
172  return _lseeki64(fd, offset, whence);
173 #else
174  return lseek(fd, offset, whence);
175 #endif
176 }
177 
179 {
180  BLI_stat_t st;
181  if ((file < 0) || (BLI_fstat(file, &st) == -1)) {
182  return -1;
183  }
184  return st.st_size;
185 }
186 
187 size_t BLI_file_size(const char *path)
188 {
189  BLI_stat_t stats;
190  if (BLI_stat(path, &stats) == -1) {
191  return -1;
192  }
193  return stats.st_size;
194 }
195 
196 /* Return file attributes. Apple version of this function is defined in storage_apple.mm */
197 #ifndef __APPLE__
199 {
200  int ret = 0;
201 
202 # ifdef WIN32
203 
204  if (BLI_path_extension_check(path, ".lnk")) {
205  return FILE_ATTR_ALIAS;
206  }
207 
208  WCHAR wline[FILE_MAXDIR];
209  if (conv_utf_8_to_16(path, wline, ARRAY_SIZE(wline)) != 0) {
210  return ret;
211  }
212  DWORD attr = GetFileAttributesW(wline);
213  if (attr & FILE_ATTRIBUTE_READONLY) {
215  }
216  if (attr & FILE_ATTRIBUTE_HIDDEN) {
218  }
219  if (attr & FILE_ATTRIBUTE_SYSTEM) {
221  }
222  if (attr & FILE_ATTRIBUTE_ARCHIVE) {
224  }
225  if (attr & FILE_ATTRIBUTE_COMPRESSED) {
227  }
228  if (attr & FILE_ATTRIBUTE_ENCRYPTED) {
230  }
231  if (attr & FILE_ATTRIBUTE_TEMPORARY) {
233  }
234  if (attr & FILE_ATTRIBUTE_SPARSE_FILE) {
236  }
237  if (attr & FILE_ATTRIBUTE_OFFLINE || attr & FILE_ATTRIBUTE_RECALL_ON_OPEN ||
238  attr & FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS) {
240  }
241  if (attr & FILE_ATTRIBUTE_REPARSE_POINT) {
243  }
244 
245 # else
246 
247  UNUSED_VARS(path);
248 
249  /* TODO:
250  * If Immutable set FILE_ATTR_READONLY
251  * If Archived set FILE_ATTR_ARCHIVE
252  */
253 # endif
254  return ret;
255 }
256 #endif
257 
258 /* Return alias/shortcut file target. Apple version is defined in storage_apple.mm */
259 #ifndef __APPLE__
260 bool BLI_file_alias_target(const char *filepath,
261  /* This parameter can only be `const` on Linux since
262  * redirections are not supported there.
263  * NOLINTNEXTLINE: readability-non-const-parameter. */
264  char r_targetpath[/*FILE_MAXDIR*/])
265 {
266 # ifdef WIN32
267  if (!BLI_path_extension_check(filepath, ".lnk")) {
268  return false;
269  }
270 
271  HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
272  if (FAILED(hr)) {
273  return false;
274  }
275 
276  IShellLinkW *Shortcut = NULL;
277  hr = CoCreateInstance(
278  &CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, &IID_IShellLinkW, (LPVOID *)&Shortcut);
279 
280  bool success = false;
281  if (SUCCEEDED(hr)) {
282  IPersistFile *PersistFile;
283  hr = Shortcut->lpVtbl->QueryInterface(Shortcut, &IID_IPersistFile, (LPVOID *)&PersistFile);
284  if (SUCCEEDED(hr)) {
285  WCHAR path_utf16[FILE_MAXDIR] = {0};
286  if (conv_utf_8_to_16(filepath, path_utf16, ARRAY_SIZE(path_utf16)) == 0) {
287  hr = PersistFile->lpVtbl->Load(PersistFile, path_utf16, STGM_READ);
288  if (SUCCEEDED(hr)) {
289  hr = Shortcut->lpVtbl->Resolve(Shortcut, 0, SLR_NO_UI | SLR_UPDATE);
290  if (SUCCEEDED(hr)) {
291  wchar_t target_utf16[FILE_MAXDIR] = {0};
292  hr = Shortcut->lpVtbl->GetPath(Shortcut, target_utf16, FILE_MAXDIR, NULL, 0);
293  if (SUCCEEDED(hr)) {
294  success = (conv_utf_16_to_8(target_utf16, r_targetpath, FILE_MAXDIR) == 0);
295  }
296  }
297  PersistFile->lpVtbl->Release(PersistFile);
298  }
299  }
300  }
301  Shortcut->lpVtbl->Release(Shortcut);
302  }
303 
304  CoUninitialize();
305  return (success && r_targetpath[0]);
306 # else
307  UNUSED_VARS(r_targetpath, filepath);
308  /* File-based redirection not supported. */
309  return false;
310 # endif
311 }
312 #endif
313 
314 int BLI_exists(const char *path)
315 {
316 #if defined(WIN32)
317  BLI_stat_t st;
318  wchar_t *tmp_16 = alloc_utf16_from_8(path, 1);
319  int len, res;
320 
321  len = wcslen(tmp_16);
322  /* in Windows #stat doesn't recognize dir ending on a slash
323  * so we remove it here */
324  if ((len > 3) && ELEM(tmp_16[len - 1], L'\\', L'/')) {
325  tmp_16[len - 1] = '\0';
326  }
327  /* two special cases where the trailing slash is needed:
328  * 1. after the share part of a UNC path
329  * 2. after the C:\ when the path is the volume only
330  */
331  if ((len >= 3) && (tmp_16[0] == L'\\') && (tmp_16[1] == L'\\')) {
332  BLI_path_normalize_unc_16(tmp_16);
333  }
334 
335  if ((tmp_16[1] == L':') && (tmp_16[2] == L'\0')) {
336  tmp_16[2] = L'\\';
337  tmp_16[3] = L'\0';
338  }
339 
340  res = BLI_wstat(tmp_16, &st);
341 
342  free(tmp_16);
343  if (res == -1) {
344  return 0;
345  }
346 #else
347  struct stat st;
348  BLI_assert(!BLI_path_is_rel(path));
349  if (stat(path, &st)) {
350  return 0;
351  }
352 #endif
353  return (st.st_mode);
354 }
355 
356 #ifdef WIN32
357 int BLI_fstat(int fd, BLI_stat_t *buffer)
358 {
359 # if defined(_MSC_VER)
360  return _fstat64(fd, buffer);
361 # else
362  return _fstat(fd, buffer);
363 # endif
364 }
365 
366 int BLI_stat(const char *path, BLI_stat_t *buffer)
367 {
368  int r;
369  UTF16_ENCODE(path);
370 
371  r = BLI_wstat(path_16, buffer);
372 
373  UTF16_UN_ENCODE(path);
374  return r;
375 }
376 
377 int BLI_wstat(const wchar_t *path, BLI_stat_t *buffer)
378 {
379 # if defined(_MSC_VER)
380  return _wstat64(path, buffer);
381 # else
382  return _wstat(path, buffer);
383 # endif
384 }
385 #else
386 int BLI_fstat(int fd, struct stat *buffer)
387 {
388  return fstat(fd, buffer);
389 }
390 
391 int BLI_stat(const char *path, struct stat *buffer)
392 {
393  return stat(path, buffer);
394 }
395 #endif
396 
397 bool BLI_is_dir(const char *file)
398 {
399  return S_ISDIR(BLI_exists(file));
400 }
401 
402 bool BLI_is_file(const char *path)
403 {
404  const int mode = BLI_exists(path);
405  return (mode && !S_ISDIR(mode));
406 }
407 
411 static void *file_read_data_as_mem_impl(FILE *fp,
412  bool read_size_exact,
413  size_t pad_bytes,
414  size_t *r_size)
415 {
416  BLI_stat_t st;
417  if (BLI_fstat(fileno(fp), &st) == -1) {
418  return NULL;
419  }
420  if (S_ISDIR(st.st_mode)) {
421  return NULL;
422  }
423  if (BLI_fseek(fp, 0L, SEEK_END) == -1) {
424  return NULL;
425  }
426  /* Don't use the 'st_size' because it may be the symlink. */
427  const long int filelen = BLI_ftell(fp);
428  if (filelen == -1) {
429  return NULL;
430  }
431  if (BLI_fseek(fp, 0L, SEEK_SET) == -1) {
432  return NULL;
433  }
434 
435  void *mem = MEM_mallocN(filelen + pad_bytes, __func__);
436  if (mem == NULL) {
437  return NULL;
438  }
439 
440  const long int filelen_read = fread(mem, 1, filelen, fp);
441  if ((filelen_read < 0) || ferror(fp)) {
442  MEM_freeN(mem);
443  return NULL;
444  }
445 
446  if (read_size_exact) {
447  if (filelen_read != filelen) {
448  MEM_freeN(mem);
449  return NULL;
450  }
451  }
452  else {
453  if (filelen_read < filelen) {
454  mem = MEM_reallocN(mem, filelen_read + pad_bytes);
455  if (mem == NULL) {
456  return NULL;
457  }
458  }
459  }
460 
461  *r_size = filelen_read;
462 
463  return mem;
464 }
465 
466 void *BLI_file_read_text_as_mem(const char *filepath, size_t pad_bytes, size_t *r_size)
467 {
468  FILE *fp = BLI_fopen(filepath, "r");
469  void *mem = NULL;
470  if (fp) {
471  mem = file_read_data_as_mem_impl(fp, false, pad_bytes, r_size);
472  fclose(fp);
473  }
474  return mem;
475 }
476 
477 void *BLI_file_read_binary_as_mem(const char *filepath, size_t pad_bytes, size_t *r_size)
478 {
479  FILE *fp = BLI_fopen(filepath, "rb");
480  void *mem = NULL;
481  if (fp) {
482  mem = file_read_data_as_mem_impl(fp, true, pad_bytes, r_size);
483  fclose(fp);
484  }
485  return mem;
486 }
487 
489  bool trim_trailing_space,
490  size_t pad_bytes,
491  size_t *r_size)
492 {
493  char *mem = BLI_file_read_text_as_mem(filepath, pad_bytes, r_size);
494  if (mem != NULL) {
495  char *mem_end = mem + *r_size;
496  if (pad_bytes != 0) {
497  *mem_end = '\0';
498  }
499  for (char *p = mem, *p_next; p != mem_end; p = p_next) {
500  p_next = memchr(p, '\n', mem_end - p);
501  if (p_next != NULL) {
502  if (trim_trailing_space) {
503  for (char *p_trim = p_next - 1; p_trim > p && ELEM(*p_trim, ' ', '\t'); p_trim--) {
504  *p_trim = '\0';
505  }
506  }
507  *p_next = '\0';
508  p_next++;
509  }
510  else {
511  p_next = mem_end;
512  }
513  }
514  }
515  return mem;
516 }
517 
518 LinkNode *BLI_file_read_as_lines(const char *filepath)
519 {
520  FILE *fp = BLI_fopen(filepath, "r");
521  LinkNodePair lines = {NULL, NULL};
522  char *buf;
523  size_t size;
524 
525  if (!fp) {
526  return NULL;
527  }
528 
529  BLI_fseek(fp, 0, SEEK_END);
530  size = (size_t)BLI_ftell(fp);
531  BLI_fseek(fp, 0, SEEK_SET);
532 
533  if (UNLIKELY(size == (size_t)-1)) {
534  fclose(fp);
535  return NULL;
536  }
537 
538  buf = MEM_mallocN(size, "file_as_lines");
539  if (buf) {
540  size_t i, last = 0;
541 
542  /*
543  * size = because on win32 reading
544  * all the bytes in the file will return
545  * less bytes because of `CRNL` changes.
546  */
547  size = fread(buf, 1, size, fp);
548  for (i = 0; i <= size; i++) {
549  if (i == size || buf[i] == '\n') {
550  char *line = BLI_strdupn(&buf[last], i - last);
551  BLI_linklist_append(&lines, line);
552  last = i + 1;
553  }
554  }
555 
556  MEM_freeN(buf);
557  }
558 
559  fclose(fp);
560 
561  return lines.list;
562 }
563 
565 {
566  BLI_linklist_freeN(lines);
567 }
568 
569 bool BLI_file_older(const char *file1, const char *file2)
570 {
571  BLI_stat_t st1, st2;
572  if (BLI_stat(file1, &st1)) {
573  return false;
574  }
575  if (BLI_stat(file2, &st2)) {
576  return false;
577  }
578  return (st1.st_mtime < st2.st_mtime);
579 }
#define BLI_assert(a)
Definition: BLI_assert.h:46
File and directory operations.
FILE * BLI_fopen(const char *filepath, const char *mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: fileops.c:906
struct stat BLI_stat_t
Definition: BLI_fileops.h:73
eFileAttributes
Definition: BLI_fileops.h:86
@ FILE_ATTR_SPARSE_FILE
Definition: BLI_fileops.h:95
@ FILE_ATTR_COMPRESSED
Definition: BLI_fileops.h:91
@ FILE_ATTR_ENCRYPTED
Definition: BLI_fileops.h:92
@ FILE_ATTR_ALIAS
Definition: BLI_fileops.h:97
@ FILE_ATTR_TEMPORARY
Definition: BLI_fileops.h:94
@ FILE_ATTR_ARCHIVE
Definition: BLI_fileops.h:90
@ FILE_ATTR_REPARSE_POINT
Definition: BLI_fileops.h:98
@ FILE_ATTR_HIDDEN
Definition: BLI_fileops.h:88
@ FILE_ATTR_READONLY
Definition: BLI_fileops.h:87
@ FILE_ATTR_SYSTEM
Definition: BLI_fileops.h:89
@ FILE_ATTR_OFFLINE
Definition: BLI_fileops.h:96
void BLI_kdtree_nd_() free(KDTree *tree)
Definition: kdtree_impl.h:102
bool BLI_path_is_rel(const char *path) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
Definition: path_util.c:347
bool BLI_path_extension_check(const char *str, const char *ext) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
Definition: path_util.c:1299
const char * BLI_getenv(const char *env) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
Definition: path_util.c:1168
#define FILE_MAXDIR
size_t BLI_strnlen(const char *str, size_t maxlen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: string.c:899
char * BLI_strdupn(const char *str, size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: string.c:33
size_t BLI_strncpy_wchar_as_utf8(char *__restrict dst, const wchar_t *__restrict src, size_t maxncpy) ATTR_NONNULL(1
#define ARRAY_SIZE(arr)
#define UNUSED_VARS(...)
#define UNLIKELY(x)
#define ELEM(...)
Compatibility-like things for windows.
#define S_ISDIR(x)
Definition: BLI_winstuff.h:48
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
Read Guarded memory(de)allocation.
#define MEM_reallocN(vmemh, len)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
FILE * file
int len
Definition: draw_manager.c:108
ccl_global float * buffer
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:33
#define L
static const pxr::TfToken st("st", pxr::TfToken::Immortal)
return ret
__int64 int64_t
Definition: stdint.h:89
eFileAttributes BLI_file_attributes(const char *path)
Definition: storage.c:198
int BLI_exists(const char *path)
Definition: storage.c:314
void * BLI_file_read_binary_as_mem(const char *filepath, size_t pad_bytes, size_t *r_size)
Definition: storage.c:477
bool BLI_file_older(const char *file1, const char *file2)
Definition: storage.c:569
void BLI_file_free_lines(LinkNode *lines)
Definition: storage.c:564
bool BLI_is_dir(const char *file)
Definition: storage.c:397
int BLI_fstat(int fd, struct stat *buffer)
Definition: storage.c:386
void * BLI_file_read_text_as_mem(const char *filepath, size_t pad_bytes, size_t *r_size)
Definition: storage.c:466
int BLI_stat(const char *path, struct stat *buffer)
Definition: storage.c:391
size_t BLI_file_descriptor_size(int file)
Definition: storage.c:178
int64_t BLI_lseek(int fd, int64_t offset, int whence)
Definition: storage.c:169
char * BLI_current_working_dir(char *dir, const size_t maxncpy)
Definition: storage.c:59
void * BLI_file_read_text_as_mem_with_newline_as_nil(const char *filepath, bool trim_trailing_space, size_t pad_bytes, size_t *r_size)
Definition: storage.c:488
double BLI_dir_free_space(const char *dir)
Definition: storage.c:83
size_t BLI_file_size(const char *path)
Definition: storage.c:187
bool BLI_file_alias_target(const char *filepath, char r_targetpath[])
Definition: storage.c:260
LinkNode * BLI_file_read_as_lines(const char *filepath)
Definition: storage.c:518
int BLI_fseek(FILE *stream, int64_t offset, int whence)
Definition: storage.c:160
static void * file_read_data_as_mem_impl(FILE *fp, bool read_size_exact, size_t pad_bytes, size_t *r_size)
Definition: storage.c:411
bool BLI_is_file(const char *path)
Definition: storage.c:402
int64_t BLI_ftell(FILE *stream)
Definition: storage.c:151
LinkNode * list
Definition: BLI_linklist.h:34
wchar_t * alloc_utf16_from_8(const char *in8, size_t add)
Definition: utfconv.c:291
int conv_utf_8_to_16(const char *in8, wchar_t *out16, size_t size16)
Definition: utfconv.c:181
int conv_utf_16_to_8(const wchar_t *in16, char *out8, size_t size8)
Definition: utfconv.c:115
#define UTF16_ENCODE(in8str)
Definition: utfconv.h:83
#define UTF16_UN_ENCODE(in8str)
Definition: utfconv.h:87