Blender V4.3
autoexec.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
12#include <cstdlib>
13#include <cstring>
14
15#include "DNA_userdef_types.h"
16
17#include "BLI_fnmatch.h"
18#include "BLI_path_utils.hh"
19#include "BLI_utildefines.h"
20
21#ifdef WIN32
22# include "BLI_string.h"
23#endif
24
25#include "BKE_autoexec.hh" /* own include */
26
27bool BKE_autoexec_match(const char *path)
28{
29 bPathCompare *path_cmp;
30
31#ifdef WIN32
32 const int fnmatch_flags = FNM_CASEFOLD;
33#else
34 const int fnmatch_flags = 0;
35#endif
36
38
39 for (path_cmp = static_cast<bPathCompare *>(U.autoexec_paths.first); path_cmp;
40 path_cmp = path_cmp->next)
41 {
42 if (path_cmp->path[0] == '\0') {
43 /* pass */
44 }
45 else if (path_cmp->flag & USER_PATHCMP_GLOB) {
46 if (fnmatch(path_cmp->path, path, fnmatch_flags) == 0) {
47 return true;
48 }
49 }
50 else if (BLI_path_ncmp(path_cmp->path, path, strlen(path_cmp->path)) == 0) {
51 return true;
52 }
53 }
54
55 return false;
56}
#define BLI_assert(a)
Definition BLI_assert.h:50
#define BLI_path_ncmp
@ USER_SCRIPT_AUTOEXEC_DISABLE
@ USER_PATHCMP_GLOB
bool BKE_autoexec_match(const char *path)
Definition autoexec.cc:27
unsigned int U
Definition btGjkEpa3.h:78
struct bPathCompare * next