Blender V5.3
storage.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#include <cstdio>
12#include <cstdlib>
13#include <sys/types.h>
14
15#include <sys/stat.h>
16
17#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__HAIKU__)
18/* Other modern unix OS's should probably use this also. */
19# include <sys/statvfs.h>
20# define USE_STATFS_STATVFS
21#endif
22
23#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || \
24 defined(__DragonFly__)
25/* For statfs */
26# include <sys/mount.h>
27# include <sys/param.h>
28#endif
29
30#if defined(__linux__) || defined(__hpux) || defined(__GNU__) || defined(__GLIBC__)
31# include <sys/vfs.h>
32#endif
33
34#include <cstring>
35#include <fcntl.h>
36
37#ifdef WIN32
38# include "BLI_string_utf8.hh"
39# include "BLI_winstuff.hh"
40# include "utfconv.hh"
41# include <ShObjIdl.h>
42# include <direct.h>
43# include <io.h>
44# include <stdbool.h>
45#else
46# include <pwd.h>
47# include <sys/ioctl.h>
48# include <unistd.h>
49#endif
50
51/* lib includes */
52#include "MEM_guardedalloc.h"
53
54#include "BLI_fileops.hh"
55#include "BLI_linklist.hh"
56#include "BLI_path_utils.hh"
57#include "BLI_string.hh"
58#include "BLI_threads.hh"
59#include "BLI_utildefines.hh"
60
61namespace blender {
62
63/* NOTE: The implementation for Apple lives in storage_apple.mm. */
64#if !defined(__APPLE__)
65bool BLI_change_working_dir(const char *dir)
66{
68
69 if (!BLI_is_dir(dir)) {
70 return false;
71 }
72# if defined(WIN32)
73 wchar_t wdir[FILE_MAX];
74 if (conv_utf_8_to_16(dir, wdir, ARRAY_SIZE(wdir)) != 0) {
75 return false;
76 }
77 return _wchdir(wdir) == 0;
78# else
79 return chdir(dir) == 0;
80# endif
81}
82
83char *BLI_current_working_dir(char *dir, const size_t maxncpy)
84{
85# if defined(WIN32)
86 wchar_t path[MAX_PATH];
87 if (_wgetcwd(path, MAX_PATH)) {
88 if (BLI_strncpy_wchar_as_utf8(dir, path, maxncpy) != maxncpy) {
89 return dir;
90 }
91 }
92 return nullptr;
93# else
94 return getcwd(dir, maxncpy);
95# endif
96}
97#endif /* !defined (__APPLE__) */
98
99const char *BLI_dir_home()
100{
101 const char *home_dir;
102
103#ifdef WIN32
104 home_dir = BLI_getenv("userprofile");
105#else
106 /* Return the users home directory with a fallback when the environment variable isn't set.
107 * Failure to access `$HOME` is rare but possible, see: #2931.
108 *
109 * Any errors accessing home is likely caused by a broken/unsupported configuration,
110 * nevertheless, failing to null check would crash which makes the error difficult
111 * for users troubleshoot. */
112 home_dir = BLI_getenv("HOME");
113 if (home_dir == nullptr) {
114 if (const passwd *pwuser = getpwuid(getuid())) {
115 home_dir = pwuser->pw_dir;
116 }
117 }
118#endif
119
120 return home_dir;
121}
122
123double BLI_dir_free_space(const char *dir)
124{
125#ifdef WIN32
126 DWORD sectorspc, bytesps, freec, clusters;
127 char tmp[4];
128
129 tmp[0] = '\\';
130 tmp[1] = 0; /* Just a fail-safe. */
131 if (ELEM(dir[0], '/', '\\')) {
132 tmp[0] = '\\';
133 tmp[1] = 0;
134 }
135 else if (dir[1] == ':') {
136 tmp[0] = dir[0];
137 tmp[1] = ':';
138 tmp[2] = '\\';
139 tmp[3] = 0;
140 }
141
142 GetDiskFreeSpace(tmp, &sectorspc, &bytesps, &freec, &clusters);
143
144 return double(freec * bytesps * sectorspc);
145#else
146
147# ifdef USE_STATFS_STATVFS
148 struct statvfs disk;
149# else
150 struct statfs disk;
151# endif
152
153 char dirname[FILE_MAXDIR], *slash;
154 int len = strlen(dir);
155
156 if (len >= FILE_MAXDIR) {
157 /* path too long */
158 return -1;
159 }
160
161 memcpy(dirname, dir, len + 1);
162
163 if (len) {
164 slash = strrchr(dirname, '/');
165 if (slash) {
166 slash[1] = '\0';
167 }
168 }
169 else {
170 dirname[0] = '/';
171 dirname[1] = '\0';
172 }
173
174# if defined(USE_STATFS_STATVFS)
175 if (statvfs(dirname, &disk)) {
176 return -1;
177 }
178# elif defined(USE_STATFS_4ARGS)
179 if (statfs(dirname, &disk, sizeof(struct statfs), 0)) {
180 return -1;
181 }
182# else
183 if (statfs(dirname, &disk)) {
184 return -1;
185 }
186# endif
187
188 return double(disk.f_bsize) * double(disk.f_bfree);
189#endif
190}
191
192int64_t BLI_ftell(FILE *stream)
193{
194#ifdef WIN32
195 return _ftelli64(stream);
196#else
197 return ftell(stream);
198#endif
199}
200
201int BLI_fseek(FILE *stream, int64_t offset, int whence)
202{
203#ifdef WIN32
204 return _fseeki64(stream, offset, whence);
205#else
206 return fseek(stream, offset, whence);
207#endif
208}
209
210int64_t BLI_lseek(int fd, int64_t offset, int whence)
211{
212#ifdef WIN32
213 return _lseeki64(fd, offset, whence);
214#else
215 return lseek(fd, offset, whence);
216#endif
217}
218
220{
221 BLI_stat_t st;
222 if ((file < 0) || (BLI_fstat(file, &st) == -1)) {
223 return -1;
224 }
225 return st.st_size;
226}
227
228size_t BLI_file_size(const char *path)
229{
230 BLI_stat_t stats;
231 if (BLI_stat(path, &stats) == -1) {
232 return -1;
233 }
234 return stats.st_size;
235}
236
237/* Return file attributes. Apple version of this function is defined in storage_apple.mm */
238#ifndef __APPLE__
240{
241 int ret = 0;
242
243# ifdef WIN32
244
245 if (BLI_path_extension_check(path, ".lnk")) {
246 return FILE_ATTR_ALIAS;
247 }
248
249 WCHAR wline[FILE_MAXDIR];
250 if (conv_utf_8_to_16(path, wline, ARRAY_SIZE(wline)) != 0) {
251 return eFileAttributes(ret);
252 }
253
254 DWORD attr = GetFileAttributesW(wline);
255 if (attr == INVALID_FILE_ATTRIBUTES) {
256 BLI_assert_msg(GetLastError() != ERROR_FILE_NOT_FOUND,
257 "BLI_file_attributes should only be called on existing files.");
258 return eFileAttributes(ret);
259 }
260
261 if (attr & FILE_ATTRIBUTE_READONLY) {
263 }
264 if (attr & FILE_ATTRIBUTE_HIDDEN) {
266 }
267 if (attr & FILE_ATTRIBUTE_SYSTEM) {
269 }
270 if (attr & FILE_ATTRIBUTE_ARCHIVE) {
272 }
273 if (attr & FILE_ATTRIBUTE_COMPRESSED) {
275 }
276 if (attr & FILE_ATTRIBUTE_ENCRYPTED) {
278 }
279 if (attr & FILE_ATTRIBUTE_TEMPORARY) {
281 }
282 if (attr & FILE_ATTRIBUTE_SPARSE_FILE) {
284 }
285 if (attr & FILE_ATTRIBUTE_OFFLINE || attr & FILE_ATTRIBUTE_RECALL_ON_OPEN ||
286 attr & FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS)
287 {
289 }
290 if (attr & FILE_ATTRIBUTE_REPARSE_POINT) {
292 }
293
294# else
295
296 UNUSED_VARS(path);
297
298 /* TODO:
299 * If Immutable set FILE_ATTR_READONLY
300 * If Archived set FILE_ATTR_ARCHIVE
301 */
302# endif
303 return eFileAttributes(ret);
304}
305#endif
306
307#ifndef __APPLE__ /* Apple version is defined in `storage_apple.mm`. */
308bool BLI_file_alias_target(const char *filepath,
309 /* This parameter can only be `const` on Linux since
310 * redirection is not supported there.
311 * NOLINTNEXTLINE: readability-non-const-parameter. */
312 char r_targetpath[FILE_MAXDIR])
313{
314# ifdef WIN32
315 if (!BLI_path_extension_check(filepath, ".lnk")) {
316 return false;
317 }
318
319 HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
320 if (FAILED(hr)) {
321 return false;
322 }
323
324 IShellLinkW *Shortcut = nullptr;
325 hr = CoCreateInstance(
326 CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_IShellLinkW, (LPVOID *)&Shortcut);
327
328 bool success = false;
329 if (SUCCEEDED(hr)) {
330 IPersistFile *PersistFile;
331 hr = Shortcut->QueryInterface(IID_IPersistFile, (LPVOID *)&PersistFile);
332 if (SUCCEEDED(hr)) {
333 WCHAR path_utf16[FILE_MAXDIR] = {0};
334 if (conv_utf_8_to_16(filepath, path_utf16, ARRAY_SIZE(path_utf16)) == 0) {
335 hr = PersistFile->Load(path_utf16, STGM_READ);
336 if (SUCCEEDED(hr)) {
337 hr = Shortcut->Resolve(0, SLR_NO_UI | SLR_UPDATE | SLR_NOSEARCH);
338 if (SUCCEEDED(hr)) {
339 wchar_t target_utf16[FILE_MAXDIR] = {0};
340 hr = Shortcut->GetPath(target_utf16, FILE_MAXDIR, nullptr, 0);
341 if (SUCCEEDED(hr)) {
342 success = (conv_utf_16_to_8(target_utf16, r_targetpath, FILE_MAXDIR) == 0);
343 }
344 }
345 PersistFile->Release();
346 }
347 }
348 }
349 Shortcut->Release();
350 }
351
352 CoUninitialize();
353 return (success && r_targetpath[0]);
354# else
355 UNUSED_VARS(r_targetpath, filepath);
356 /* File-based redirection not supported. */
357 return false;
358# endif
359}
360#endif
361
362int BLI_file_stat_mode(const char *path)
363{
364#if defined(WIN32)
365 BLI_stat_t st;
366 wchar_t *tmp_16 = alloc_utf16_from_8(path, 1);
367 int len, res;
368
369 len = wcslen(tmp_16);
370 /* in Windows #stat doesn't recognize dir ending on a slash
371 * so we remove it here */
372 if ((len > 3) && ELEM(tmp_16[len - 1], L'\\', L'/')) {
373 tmp_16[len - 1] = '\0';
374 }
375 /* two special cases where the trailing slash is needed:
376 * 1. after the share part of a UNC path
377 * 2. after the C:\ when the path is the volume only
378 */
379 if ((len >= 3) && (tmp_16[0] == L'\\') && (tmp_16[1] == L'\\')) {
380 BLI_path_normalize_unc_16(tmp_16);
381 }
382
383 if ((tmp_16[1] == L':') && (tmp_16[2] == L'\0')) {
384 tmp_16[2] = L'\\';
385 tmp_16[3] = L'\0';
386 }
387
388 res = BLI_wstat(tmp_16, &st);
389
390 free(tmp_16);
391 if (res == -1) {
392 return 0;
393 }
394#else
395 struct stat st;
397 if (stat(path, &st)) {
398 return 0;
399 }
400#endif
401 return (st.st_mode);
402}
403
404bool BLI_exists(const char *path)
405{
406#ifdef WIN32
407 wchar_t *path_16 = alloc_utf16_from_8(path, 0);
408 const bool exists = (GetFileAttributesW(path_16) != INVALID_FILE_ATTRIBUTES);
409 free(path_16);
410 return exists;
411#else
412 return BLI_file_stat_mode(path) != 0;
413#endif
414}
415
416#ifdef WIN32
417int BLI_fstat(int fd, BLI_stat_t *buffer)
418{
419# if defined(_MSC_VER)
420 return _fstat64(fd, buffer);
421# else
422 return _fstat(fd, buffer);
423# endif
424}
425
426int BLI_stat(const char *path, BLI_stat_t *buffer)
427{
428 int r;
429 UTF16_ENCODE(path);
430
431 r = BLI_wstat(path_16, buffer);
432
433 UTF16_UN_ENCODE(path);
434 return r;
435}
436
437int BLI_wstat(const wchar_t *path, BLI_stat_t *buffer)
438{
439# if defined(_MSC_VER)
440 return _wstat64(path, buffer);
441# else
442 return _wstat(path, buffer);
443# endif
444}
445#else
446int BLI_fstat(int fd, struct stat *buffer)
447{
448 return fstat(fd, buffer);
449}
450
451int BLI_stat(const char *path, struct stat *buffer)
452{
453 return stat(path, buffer);
454}
455#endif
456
457bool BLI_is_dir(const char *path)
458{
459#ifdef WIN32
460 wchar_t *tmp_16 = alloc_utf16_from_8(path, 1);
461 const DWORD attr = GetFileAttributesW(tmp_16);
462 free(tmp_16);
463 return (attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_DIRECTORY));
464#else
465 return S_ISDIR(BLI_file_stat_mode(path));
466#endif
467}
468
469bool BLI_is_file(const char *path)
470{
471#ifdef WIN32
472 wchar_t *tmp_16 = alloc_utf16_from_8(path, 1);
473 const DWORD attr = GetFileAttributesW(tmp_16);
474 free(tmp_16);
475 return (attr != INVALID_FILE_ATTRIBUTES && !(attr & FILE_ATTRIBUTE_DIRECTORY));
476#else
477 const int mode = BLI_file_stat_mode(path);
478 return (mode && !S_ISDIR(mode));
479#endif
480}
481
483 bool read_size_exact,
484 size_t pad_bytes,
485 size_t *r_size)
486{
487 /* NOTE: Used for both text and binary file reading. */
488
489 BLI_stat_t st;
490 if (BLI_fstat(fileno(fp), &st) == -1) {
491 return nullptr;
492 }
493 if (S_ISDIR(st.st_mode)) {
494 return nullptr;
495 }
496 if (BLI_fseek(fp, 0L, SEEK_END) == -1) {
497 return nullptr;
498 }
499 /* Don't use the 'st_size' because it may be the symlink. */
500 const long int filelen = BLI_ftell(fp);
501 if (filelen == -1) {
502 return nullptr;
503 }
504 if (BLI_fseek(fp, 0L, SEEK_SET) == -1) {
505 return nullptr;
506 }
507
508 void *mem = MEM_new_uninitialized(filelen + pad_bytes, __func__);
509 if (mem == nullptr) {
510 return nullptr;
511 }
512
513 const long int filelen_read = fread(mem, 1, filelen, fp);
514 if ((filelen_read < 0) || ferror(fp)) {
515 MEM_delete_void(mem);
516 return nullptr;
517 }
518
519 if (read_size_exact) {
520 if (filelen_read != filelen) {
521 MEM_delete_void(mem);
522 return nullptr;
523 }
524 }
525 else {
526 if (filelen_read < filelen) {
527 mem = MEM_realloc_uninitialized(mem, filelen_read + pad_bytes);
528 if (mem == nullptr) {
529 return nullptr;
530 }
531 }
532 }
533
534 *r_size = filelen_read;
535
536 return mem;
537}
538
539char *BLI_file_read_text_as_mem(const char *filepath, size_t pad_bytes, size_t *r_size)
540{
541 FILE *fp = BLI_fopen(filepath, "r");
542 char *mem = nullptr;
543 if (fp) {
544 mem = static_cast<char *>(BLI_file_read_data_as_mem_from_handle(fp, false, pad_bytes, r_size));
545 fclose(fp);
546 }
547 return mem;
548}
549
550void *BLI_file_read_binary_as_mem(const char *filepath, size_t pad_bytes, size_t *r_size)
551{
552 FILE *fp = BLI_fopen(filepath, "rb");
553 void *mem = nullptr;
554 if (fp) {
555 mem = BLI_file_read_data_as_mem_from_handle(fp, true, pad_bytes, r_size);
556 fclose(fp);
557 }
558 return mem;
559}
560
562 bool trim_trailing_space,
563 size_t pad_bytes,
564 size_t *r_size)
565{
566 char *mem = BLI_file_read_text_as_mem(filepath, pad_bytes, r_size);
567 if (mem != nullptr) {
568 char *mem_end = mem + *r_size;
569 if (pad_bytes != 0) {
570 *mem_end = '\0';
571 }
572 for (char *p = mem, *p_next; p != mem_end; p = p_next) {
573 p_next = static_cast<char *>(memchr(p, '\n', mem_end - p));
574 if (p_next != nullptr) {
575 if (trim_trailing_space) {
576 for (char *p_trim = p_next - 1; p_trim > p && ELEM(*p_trim, ' ', '\t'); p_trim--) {
577 *p_trim = '\0';
578 }
579 }
580 *p_next = '\0';
581 p_next++;
582 }
583 else {
584 p_next = mem_end;
585 }
586 }
587 }
588 return mem;
589}
590
591LinkNode *BLI_file_read_as_lines(const char *filepath)
592{
593 FILE *fp = BLI_fopen(filepath, "r");
594 LinkNodePair lines = {nullptr, nullptr};
595 char *buf;
596 size_t size;
597
598 if (!fp) {
599 return nullptr;
600 }
601
602 BLI_fseek(fp, 0, SEEK_END);
603 size = size_t(BLI_ftell(fp));
604 BLI_fseek(fp, 0, SEEK_SET);
605
606 if (size == size_t(-1)) [[unlikely]] {
607 fclose(fp);
608 return nullptr;
609 }
610
611 buf = MEM_new_array_zeroed<char>(size, "file_as_lines");
612 if (buf) {
613 size_t i, last = 0;
614
615 /*
616 * size = because on win32 reading
617 * all the bytes in the file will return
618 * less bytes because of `CRNL` changes.
619 */
620 size = fread(buf, 1, size, fp);
621 for (i = 0; i <= size; i++) {
622 if (i == size || buf[i] == '\n') {
623 char *line = BLI_strdupn(&buf[last], i - last);
624 BLI_linklist_append(&lines, line);
625 last = i + 1;
626 }
627 }
628
629 MEM_delete(buf);
630 }
631
632 fclose(fp);
633
634 return lines.list;
635}
636
638{
639 BLI_linklist_freeN(lines);
640}
641
642bool BLI_file_older(const char *file1, const char *file2)
643{
644 BLI_stat_t st1, st2;
645 if (BLI_stat(file1, &st1)) {
646 return false;
647 }
648 if (BLI_stat(file2, &st2)) {
649 return false;
650 }
651 return (st1.st_mtime < st2.st_mtime);
652}
653
654} // namespace blender
File and directory operations.
#define FILE_MAX
#define FILE_MAXDIR
Compatibility-like things for windows.
#define S_ISDIR(x)
const char * dirname(char *path)
Read Blender memory allocation and freeing.
#define UNUSED_VARS(...)
#define ELEM(...)
#define BLI_assert_msg(a, msg)
#define MEM_realloc_uninitialized(vmemh, len)
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263
#define L
void free(Subdiv *subdiv)
Definition subdiv.cc:192
BMesh Iterators.
void * MEM_new_uninitialized(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
__int64 int64_t
Definition BKE_text.h:90
int BLI_fstat(int fd, BLI_stat_t *buffer) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
bool BLI_change_working_dir(const char *dir)
Definition storage.cc:65
bool BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:404
FILE * BLI_fopen(const char *filepath, const char *mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
int BLI_fseek(FILE *stream, int64_t offset, int whence)
Definition storage.cc:201
char * BLI_strdupn(const char *str, size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_file_stat_mode(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:362
eFileAttributes BLI_file_attributes(const char *path)
Definition storage.cc:239
void MEM_delete_void(void *vmemh)
void * BLI_file_read_binary_as_mem(const char *filepath, size_t pad_bytes, size_t *r_size)
Definition storage.cc:550
const char * BLI_dir_home()
Definition storage.cc:99
@ FILE_ATTR_HIDDEN
@ FILE_ATTR_TEMPORARY
@ FILE_ATTR_READONLY
@ FILE_ATTR_ARCHIVE
@ FILE_ATTR_OFFLINE
@ FILE_ATTR_COMPRESSED
@ FILE_ATTR_ENCRYPTED
@ FILE_ATTR_SPARSE_FILE
@ FILE_ATTR_ALIAS
@ FILE_ATTR_REPARSE_POINT
@ FILE_ATTR_SYSTEM
struct LinkNode * BLI_file_read_as_lines(const char *filepath) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:591
void * BLI_file_read_data_as_mem_from_handle(FILE *fp, bool read_size_exact, size_t pad_bytes, size_t *r_size)
Definition storage.cc:482
char * BLI_file_read_text_as_mem(const char *filepath, size_t pad_bytes, size_t *r_size)
Definition storage.cc:539
void BLI_linklist_freeN(LinkNode *list)
double BLI_dir_free_space(const char *dir) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:123
int BLI_stat(const char *path, BLI_stat_t *buffer) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
size_t BLI_strncpy_wchar_as_utf8(char *__restrict dst, const wchar_t *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
int BLI_thread_is_main()
Definition threads.cc:184
int64_t BLI_lseek(int fd, int64_t offset, int whence)
Definition storage.cc:210
bool BLI_is_dir(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:457
size_t BLI_file_size(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:228
void void void void BLI_linklist_append(LinkNodePair *list_pair, void *ptr) ATTR_NONNULL(1)
bool BLI_path_is_rel(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
bool BLI_path_extension_check(const char *path, const char *ext) ATTR_NONNULL(1
bool BLI_file_older(const char *file1, const char *file2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:642
size_t BLI_file_descriptor_size(int file) ATTR_WARN_UNUSED_RESULT
Definition storage.cc:219
char * 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.cc:561
struct stat BLI_stat_t
bool BLI_file_alias_target(const char *filepath, char r_targetpath[768]) ATTR_WARN_UNUSED_RESULT
int64_t BLI_ftell(FILE *stream) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:192
char * BLI_current_working_dir(char *dir, size_t maxncpy) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:83
void BLI_file_free_lines(struct LinkNode *lines)
Definition storage.cc:637
bool BLI_is_file(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:469
const char * BLI_getenv(const char *env) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
wchar_t * alloc_utf16_from_8(const char *in8, size_t add)
Definition utfconv.cc:294
int conv_utf_8_to_16(const char *in8, wchar_t *out16, size_t size16)
Definition utfconv.cc:182
int conv_utf_16_to_8(const wchar_t *in16, char *out8, size_t size8)
Definition utfconv.cc:116
#define UTF16_ENCODE(in8str)
Definition utfconv.hh:80
#define UTF16_UN_ENCODE(in8str)
Definition utfconv.hh:84