Blender  V2.93
storage.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <sys/types.h>
29 
30 #include <sys/stat.h>
31 
32 #if defined(__NetBSD__) || defined(__DragonFly__) || defined(__HAIKU__)
33 /* Other modern unix OS's should probably use this also. */
34 # include <sys/statvfs.h>
35 # define USE_STATFS_STATVFS
36 #endif
37 
38 #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || \
39  defined(__DragonFly__)
40 /* For statfs */
41 # include <sys/mount.h>
42 # include <sys/param.h>
43 #endif
44 
45 #if defined(__linux__) || defined(__hpux) || defined(__GNU__) || defined(__GLIBC__)
46 # include <sys/vfs.h>
47 #endif
48 
49 #include <fcntl.h>
50 #include <string.h> /* strcpy etc.. */
51 
52 #ifdef WIN32
53 # include "BLI_string_utf8.h"
54 # include "BLI_winstuff.h"
55 # include "utfconv.h"
56 # include <ShObjIdl.h>
57 # include <direct.h>
58 # include <io.h>
59 # include <stdbool.h>
60 #else
61 # include <pwd.h>
62 # include <sys/ioctl.h>
63 # include <unistd.h>
64 #endif
65 
66 /* lib includes */
67 #include "MEM_guardedalloc.h"
68 
69 #include "BLI_fileops.h"
70 #include "BLI_linklist.h"
71 #include "BLI_path_util.h"
72 #include "BLI_string.h"
73 #include "BLI_utildefines.h"
74 
81 char *BLI_current_working_dir(char *dir, const size_t maxncpy)
82 {
83 #if defined(WIN32)
84  wchar_t path[MAX_PATH];
85  if (_wgetcwd(path, MAX_PATH)) {
86  if (BLI_strncpy_wchar_as_utf8(dir, path, maxncpy) != maxncpy) {
87  return dir;
88  }
89  }
90  return NULL;
91 #else
92  const char *pwd = BLI_getenv("PWD");
93  if (pwd) {
94  size_t srclen = BLI_strnlen(pwd, maxncpy);
95  if (srclen != maxncpy) {
96  memcpy(dir, pwd, srclen + 1);
97  return dir;
98  }
99  return NULL;
100  }
101  return getcwd(dir, maxncpy);
102 #endif
103 }
104 
107 /* Not actually used anywhere.
108  */
109 double BLI_dir_free_space(const char *dir)
110 {
111 #ifdef WIN32
112  DWORD sectorspc, bytesps, freec, clusters;
113  char tmp[4];
114 
115  tmp[0] = '\\';
116  tmp[1] = 0; /* Just a fail-safe. */
117  if (ELEM(dir[0], '/', '\\')) {
118  tmp[0] = '\\';
119  tmp[1] = 0;
120  }
121  else if (dir[1] == ':') {
122  tmp[0] = dir[0];
123  tmp[1] = ':';
124  tmp[2] = '\\';
125  tmp[3] = 0;
126  }
127 
128  GetDiskFreeSpace(tmp, &sectorspc, &bytesps, &freec, &clusters);
129 
130  return (double)(freec * bytesps * sectorspc);
131 #else
132 
133 # ifdef USE_STATFS_STATVFS
134  struct statvfs disk;
135 # else
136  struct statfs disk;
137 # endif
138 
139  char name[FILE_MAXDIR], *slash;
140  int len = strlen(dir);
141 
142  if (len >= FILE_MAXDIR) {
143  /* path too long */
144  return -1;
145  }
146 
147  strcpy(name, dir);
148 
149  if (len) {
150  slash = strrchr(name, '/');
151  if (slash) {
152  slash[1] = 0;
153  }
154  }
155  else {
156  strcpy(name, "/");
157  }
158 
159 # if defined(USE_STATFS_STATVFS)
160  if (statvfs(name, &disk)) {
161  return -1;
162  }
163 # elif defined(USE_STATFS_4ARGS)
164  if (statfs(name, &disk, sizeof(struct statfs), 0)) {
165  return -1;
166  }
167 # else
168  if (statfs(name, &disk)) {
169  return -1;
170  }
171 # endif
172 
173  return (((double)disk.f_bsize) * ((double)disk.f_bfree));
174 #endif
175 }
176 
177 int64_t BLI_ftell(FILE *stream)
178 {
179 #ifdef WIN32
180  return _ftelli64(stream);
181 #else
182  return ftell(stream);
183 #endif
184 }
185 
186 int BLI_fseek(FILE *stream, int64_t offset, int whence)
187 {
188 #ifdef WIN32
189  return _fseeki64(stream, offset, whence);
190 #else
191  return fseek(stream, offset, whence);
192 #endif
193 }
194 
195 int64_t BLI_lseek(int fd, int64_t offset, int whence)
196 {
197 #ifdef WIN32
198  return _lseeki64(fd, offset, whence);
199 #else
200  return lseek(fd, offset, whence);
201 #endif
202 }
203 
208 {
209  BLI_stat_t st;
210  if ((file < 0) || (BLI_fstat(file, &st) == -1)) {
211  return -1;
212  }
213  return st.st_size;
214 }
215 
219 size_t BLI_file_size(const char *path)
220 {
221  BLI_stat_t stats;
222  if (BLI_stat(path, &stats) == -1) {
223  return -1;
224  }
225  return stats.st_size;
226 }
227 
228 /* Return file attributes. Apple version of this function is defined in storage_apple.mm */
229 #ifndef __APPLE__
231 {
232  int ret = 0;
233 
234 # ifdef WIN32
235 
236  if (BLI_path_extension_check(path, ".lnk")) {
237  return FILE_ATTR_ALIAS;
238  }
239 
240  WCHAR wline[FILE_MAXDIR];
241  if (conv_utf_8_to_16(path, wline, ARRAY_SIZE(wline)) != 0) {
242  return ret;
243  }
244  DWORD attr = GetFileAttributesW(wline);
245  if (attr & FILE_ATTRIBUTE_READONLY) {
247  }
248  if (attr & FILE_ATTRIBUTE_HIDDEN) {
250  }
251  if (attr & FILE_ATTRIBUTE_SYSTEM) {
253  }
254  if (attr & FILE_ATTRIBUTE_ARCHIVE) {
256  }
257  if (attr & FILE_ATTRIBUTE_COMPRESSED) {
259  }
260  if (attr & FILE_ATTRIBUTE_ENCRYPTED) {
262  }
263  if (attr & FILE_ATTRIBUTE_TEMPORARY) {
265  }
266  if (attr & FILE_ATTRIBUTE_SPARSE_FILE) {
268  }
269  if (attr & FILE_ATTRIBUTE_OFFLINE) {
271  }
272  if (attr & FILE_ATTRIBUTE_REPARSE_POINT) {
274  }
275 
276 # else
277 
278  UNUSED_VARS(path);
279 
280  /* TODO:
281  * If Immutable set FILE_ATTR_READONLY
282  * If Archived set FILE_ATTR_ARCHIVE
283  */
284 # endif
285  return ret;
286 }
287 #endif
288 
289 /* Return alias/shortcut file target. Apple version is defined in storage_apple.mm */
290 #ifndef __APPLE__
291 bool BLI_file_alias_target(const char *filepath,
292  /* This parameter can only be `const` on Linux since
293  * redirections are not supported there.
294  * NOLINTNEXTLINE: readability-non-const-parameter. */
295  char r_targetpath[FILE_MAXDIR])
296 {
297 # ifdef WIN32
298  if (!BLI_path_extension_check(filepath, ".lnk")) {
299  return false;
300  }
301 
302  HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
303  if (FAILED(hr)) {
304  return false;
305  }
306 
307  IShellLinkW *Shortcut = NULL;
308  hr = CoCreateInstance(
309  &CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, &IID_IShellLinkW, (LPVOID *)&Shortcut);
310 
311  bool success = false;
312  if (SUCCEEDED(hr)) {
313  IPersistFile *PersistFile;
314  hr = Shortcut->lpVtbl->QueryInterface(Shortcut, &IID_IPersistFile, (LPVOID *)&PersistFile);
315  if (SUCCEEDED(hr)) {
316  WCHAR path_utf16[FILE_MAXDIR] = {0};
317  if (conv_utf_8_to_16(filepath, path_utf16, ARRAY_SIZE(path_utf16)) == 0) {
318  hr = PersistFile->lpVtbl->Load(PersistFile, path_utf16, STGM_READ);
319  if (SUCCEEDED(hr)) {
320  hr = Shortcut->lpVtbl->Resolve(Shortcut, 0, SLR_NO_UI | SLR_UPDATE);
321  if (SUCCEEDED(hr)) {
322  wchar_t target_utf16[FILE_MAXDIR] = {0};
323  hr = Shortcut->lpVtbl->GetPath(Shortcut, target_utf16, FILE_MAXDIR, NULL, 0);
324  if (SUCCEEDED(hr)) {
325  success = (conv_utf_16_to_8(target_utf16, r_targetpath, FILE_MAXDIR) == 0);
326  }
327  }
328  PersistFile->lpVtbl->Release(PersistFile);
329  }
330  }
331  }
332  Shortcut->lpVtbl->Release(Shortcut);
333  }
334 
335  CoUninitialize();
336  return (success && r_targetpath[0]);
337 # else
338  UNUSED_VARS(r_targetpath, filepath);
339  /* File-based redirection not supported. */
340  return false;
341 # endif
342 }
343 #endif
344 
349 int BLI_exists(const char *path)
350 {
351 #if defined(WIN32)
352  BLI_stat_t st;
353  wchar_t *tmp_16 = alloc_utf16_from_8(path, 1);
354  int len, res;
355 
356  len = wcslen(tmp_16);
357  /* in Windows #stat doesn't recognize dir ending on a slash
358  * so we remove it here */
359  if ((len > 3) && ELEM(tmp_16[len - 1], L'\\', L'/')) {
360  tmp_16[len - 1] = '\0';
361  }
362  /* two special cases where the trailing slash is needed:
363  * 1. after the share part of a UNC path
364  * 2. after the C:\ when the path is the volume only
365  */
366  if ((len >= 3) && (tmp_16[0] == L'\\') && (tmp_16[1] == L'\\')) {
367  BLI_path_normalize_unc_16(tmp_16);
368  }
369 
370  if ((tmp_16[1] == L':') && (tmp_16[2] == L'\0')) {
371  tmp_16[2] = L'\\';
372  tmp_16[3] = L'\0';
373  }
374 
375  res = BLI_wstat(tmp_16, &st);
376 
377  free(tmp_16);
378  if (res == -1) {
379  return 0;
380  }
381 #else
382  struct stat st;
383  BLI_assert(!BLI_path_is_rel(path));
384  if (stat(path, &st)) {
385  return 0;
386  }
387 #endif
388  return (st.st_mode);
389 }
390 
391 #ifdef WIN32
392 int BLI_fstat(int fd, BLI_stat_t *buffer)
393 {
394 # if defined(_MSC_VER)
395  return _fstat64(fd, buffer);
396 # else
397  return _fstat(fd, buffer);
398 # endif
399 }
400 
401 int BLI_stat(const char *path, BLI_stat_t *buffer)
402 {
403  int r;
404  UTF16_ENCODE(path);
405 
406  r = BLI_wstat(path_16, buffer);
407 
408  UTF16_UN_ENCODE(path);
409  return r;
410 }
411 
412 int BLI_wstat(const wchar_t *path, BLI_stat_t *buffer)
413 {
414 # if defined(_MSC_VER)
415  return _wstat64(path, buffer);
416 # else
417  return _wstat(path, buffer);
418 # endif
419 }
420 #else
421 int BLI_fstat(int fd, struct stat *buffer)
422 {
423  return fstat(fd, buffer);
424 }
425 
426 int BLI_stat(const char *path, struct stat *buffer)
427 {
428  return stat(path, buffer);
429 }
430 #endif
431 
436 bool BLI_is_dir(const char *file)
437 {
438  return S_ISDIR(BLI_exists(file));
439 }
440 
444 bool BLI_is_file(const char *path)
445 {
446  const int mode = BLI_exists(path);
447  return (mode && !S_ISDIR(mode));
448 }
449 
453 static void *file_read_data_as_mem_impl(FILE *fp,
454  bool read_size_exact,
455  size_t pad_bytes,
456  size_t *r_size)
457 {
458  BLI_stat_t st;
459  if (BLI_fstat(fileno(fp), &st) == -1) {
460  return NULL;
461  }
462  if (S_ISDIR(st.st_mode)) {
463  return NULL;
464  }
465  if (BLI_fseek(fp, 0L, SEEK_END) == -1) {
466  return NULL;
467  }
468  /* Don't use the 'st_size' because it may be the symlink. */
469  const long int filelen = BLI_ftell(fp);
470  if (filelen == -1) {
471  return NULL;
472  }
473  if (BLI_fseek(fp, 0L, SEEK_SET) == -1) {
474  return NULL;
475  }
476 
477  void *mem = MEM_mallocN(filelen + pad_bytes, __func__);
478  if (mem == NULL) {
479  return NULL;
480  }
481 
482  const long int filelen_read = fread(mem, 1, filelen, fp);
483  if ((filelen_read < 0) || ferror(fp)) {
484  MEM_freeN(mem);
485  return NULL;
486  }
487 
488  if (read_size_exact) {
489  if (filelen_read != filelen) {
490  MEM_freeN(mem);
491  return NULL;
492  }
493  }
494  else {
495  if (filelen_read < filelen) {
496  mem = MEM_reallocN(mem, filelen_read + pad_bytes);
497  if (mem == NULL) {
498  return NULL;
499  }
500  }
501  }
502 
503  *r_size = filelen_read;
504 
505  return mem;
506 }
507 
508 void *BLI_file_read_text_as_mem(const char *filepath, size_t pad_bytes, size_t *r_size)
509 {
510  FILE *fp = BLI_fopen(filepath, "r");
511  void *mem = NULL;
512  if (fp) {
513  mem = file_read_data_as_mem_impl(fp, false, pad_bytes, r_size);
514  fclose(fp);
515  }
516  return mem;
517 }
518 
519 void *BLI_file_read_binary_as_mem(const char *filepath, size_t pad_bytes, size_t *r_size)
520 {
521  FILE *fp = BLI_fopen(filepath, "rb");
522  void *mem = NULL;
523  if (fp) {
524  mem = file_read_data_as_mem_impl(fp, true, pad_bytes, r_size);
525  fclose(fp);
526  }
527  return mem;
528 }
529 
558  bool trim_trailing_space,
559  size_t pad_bytes,
560  size_t *r_size)
561 {
562  char *mem = BLI_file_read_text_as_mem(filepath, pad_bytes, r_size);
563  if (mem != NULL) {
564  char *mem_end = mem + *r_size;
565  if (pad_bytes != 0) {
566  *mem_end = '\0';
567  }
568  for (char *p = mem, *p_next; p != mem_end; p = p_next) {
569  p_next = memchr(p, '\n', mem_end - p);
570  if (p_next != NULL) {
571  if (trim_trailing_space) {
572  for (char *p_trim = p_next - 1; p_trim > p && ELEM(*p_trim, ' ', '\t'); p_trim--) {
573  *p_trim = '\0';
574  }
575  }
576  *p_next = '\0';
577  p_next++;
578  }
579  else {
580  p_next = mem_end;
581  }
582  }
583  }
584  return mem;
585 }
586 
590 LinkNode *BLI_file_read_as_lines(const char *filepath)
591 {
592  FILE *fp = BLI_fopen(filepath, "r");
593  LinkNodePair lines = {NULL, NULL};
594  char *buf;
595  size_t size;
596 
597  if (!fp) {
598  return NULL;
599  }
600 
601  BLI_fseek(fp, 0, SEEK_END);
602  size = (size_t)BLI_ftell(fp);
603  BLI_fseek(fp, 0, SEEK_SET);
604 
605  if (UNLIKELY(size == (size_t)-1)) {
606  fclose(fp);
607  return NULL;
608  }
609 
610  buf = MEM_mallocN(size, "file_as_lines");
611  if (buf) {
612  size_t i, last = 0;
613 
614  /*
615  * size = because on win32 reading
616  * all the bytes in the file will return
617  * less bytes because of `CRNL` changes.
618  */
619  size = fread(buf, 1, size, fp);
620  for (i = 0; i <= size; i++) {
621  if (i == size || buf[i] == '\n') {
622  char *line = BLI_strdupn(&buf[last], i - last);
623  BLI_linklist_append(&lines, line);
624  last = i + 1;
625  }
626  }
627 
628  MEM_freeN(buf);
629  }
630 
631  fclose(fp);
632 
633  return lines.list;
634 }
635 
636 /*
637  * Frees memory from a previous call to BLI_file_read_as_lines.
638  */
640 {
641  BLI_linklist_freeN(lines);
642 }
643 
645 bool BLI_file_older(const char *file1, const char *file2)
646 {
647 #ifdef WIN32
648  struct _stat st1, st2;
649 
650  UTF16_ENCODE(file1);
651  UTF16_ENCODE(file2);
652 
653  if (_wstat(file1_16, &st1)) {
654  return false;
655  }
656  if (_wstat(file2_16, &st2)) {
657  return false;
658  }
659 
660  UTF16_UN_ENCODE(file2);
661  UTF16_UN_ENCODE(file1);
662 #else
663  struct stat st1, st2;
664 
665  if (stat(file1, &st1)) {
666  return false;
667  }
668  if (stat(file2, &st2)) {
669  return false;
670  }
671 #endif
672  return (st1.st_mtime < st2.st_mtime);
673 }
#define BLI_assert(a)
Definition: BLI_assert.h:58
File and directory operations.
struct stat BLI_stat_t
Definition: BLI_fileops.h:67
eFileAttributes
Definition: BLI_fileops.h:80
@ FILE_ATTR_SPARSE_FILE
Definition: BLI_fileops.h:89
@ FILE_ATTR_COMPRESSED
Definition: BLI_fileops.h:85
@ FILE_ATTR_ENCRYPTED
Definition: BLI_fileops.h:86
@ FILE_ATTR_ALIAS
Definition: BLI_fileops.h:91
@ FILE_ATTR_TEMPORARY
Definition: BLI_fileops.h:88
@ FILE_ATTR_ARCHIVE
Definition: BLI_fileops.h:84
@ FILE_ATTR_REPARSE_POINT
Definition: BLI_fileops.h:92
@ FILE_ATTR_HIDDEN
Definition: BLI_fileops.h:82
@ FILE_ATTR_READONLY
Definition: BLI_fileops.h:81
@ FILE_ATTR_SYSTEM
Definition: BLI_fileops.h:83
@ FILE_ATTR_OFFLINE
Definition: BLI_fileops.h:90
FILE * BLI_fopen(const char *filename, const char *mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: fileops.c:1003
void BLI_kdtree_nd_() free(KDTree *tree)
Definition: kdtree_impl.h:116
bool BLI_path_is_rel(const char *path) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
Definition: path_util.c:411
bool BLI_path_extension_check(const char *str, const char *ext) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
Definition: path_util.c:1459
const char * BLI_getenv(const char *env) ATTR_NONNULL(1)
Definition: path_util.c:1313
#define FILE_MAXDIR
char * BLI_strdupn(const char *str, const size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: string.c:54
size_t BLI_strnlen(const char *str, const size_t maxlen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: string.c:878
size_t BLI_strncpy_wchar_as_utf8(char *__restrict dst, const wchar_t *__restrict src, const size_t maxncpy) ATTR_NONNULL()
Definition: string_utf8.c:295
#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:64
typedef LPVOID
_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
__kernel void ccl_constant KernelData ccl_global void ccl_global char ccl_global int ccl_global char ccl_global unsigned int ccl_global float * buffer
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:47
#define L
return ret
__int64 int64_t
Definition: stdint.h:92
eFileAttributes BLI_file_attributes(const char *path)
Definition: storage.c:230
int BLI_exists(const char *path)
Definition: storage.c:349
void * BLI_file_read_binary_as_mem(const char *filepath, size_t pad_bytes, size_t *r_size)
Definition: storage.c:519
bool BLI_file_older(const char *file1, const char *file2)
Definition: storage.c:645
void BLI_file_free_lines(LinkNode *lines)
Definition: storage.c:639
bool BLI_is_dir(const char *file)
Definition: storage.c:436
int BLI_fstat(int fd, struct stat *buffer)
Definition: storage.c:421
void * BLI_file_read_text_as_mem(const char *filepath, size_t pad_bytes, size_t *r_size)
Definition: storage.c:508
bool BLI_file_alias_target(const char *filepath, char r_targetpath[FILE_MAXDIR])
Definition: storage.c:291
int BLI_stat(const char *path, struct stat *buffer)
Definition: storage.c:426
size_t BLI_file_descriptor_size(int file)
Definition: storage.c:207
int64_t BLI_lseek(int fd, int64_t offset, int whence)
Definition: storage.c:195
char * BLI_current_working_dir(char *dir, const size_t maxncpy)
Definition: storage.c:81
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:557
double BLI_dir_free_space(const char *dir)
Definition: storage.c:109
size_t BLI_file_size(const char *path)
Definition: storage.c:219
LinkNode * BLI_file_read_as_lines(const char *filepath)
Definition: storage.c:590
int BLI_fseek(FILE *stream, int64_t offset, int whence)
Definition: storage.c:186
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:453
bool BLI_is_file(const char *path)
Definition: storage.c:444
int64_t BLI_ftell(FILE *stream)
Definition: storage.c:177
LinkNode * list
Definition: BLI_linklist.h:50
wchar_t * alloc_utf16_from_8(const char *in8, size_t add)
Definition: utfconv.c:296
int conv_utf_8_to_16(const char *in8, wchar_t *out16, size_t size16)
Definition: utfconv.c:189
int conv_utf_16_to_8(const wchar_t *in16, char *out8, size_t size8)
Definition: utfconv.c:127
#define UTF16_ENCODE(in8str)
Definition: utfconv.h:96
#define UTF16_UN_ENCODE(in8str)
Definition: utfconv.h:100
uint len