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