Blender  V2.93
autoexec.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 
24 #include <stdlib.h>
25 #include <string.h>
26 
27 #include "DNA_userdef_types.h"
28 
29 #include "BLI_fnmatch.h"
30 #include "BLI_path_util.h"
31 #include "BLI_utildefines.h"
32 
33 #ifdef WIN32
34 # include "BLI_string.h"
35 #endif
36 
37 #include "BKE_autoexec.h" /* own include */
38 
43 bool BKE_autoexec_match(const char *path)
44 {
45  bPathCompare *path_cmp;
46 
47 #ifdef WIN32
48  const int fnmatch_flags = FNM_CASEFOLD;
49 #else
50  const int fnmatch_flags = 0;
51 #endif
52 
54 
55  for (path_cmp = U.autoexec_paths.first; path_cmp; path_cmp = path_cmp->next) {
56  if (path_cmp->path[0] == '\0') {
57  /* pass */
58  }
59  else if ((path_cmp->flag & USER_PATHCMP_GLOB)) {
60  if (fnmatch(path_cmp->path, path, fnmatch_flags) == 0) {
61  return true;
62  }
63  }
64  else if (BLI_path_ncmp(path_cmp->path, path, strlen(path_cmp->path)) == 0) {
65  return true;
66  }
67  }
68 
69  return false;
70 }
#define BLI_assert(a)
Definition: BLI_assert.h:58
#define BLI_path_ncmp
@ USER_SCRIPT_AUTOEXEC_DISABLE
@ USER_PATHCMP_GLOB
bool BKE_autoexec_match(const char *path)
Definition: autoexec.c:43
unsigned int U
Definition: btGjkEpa3.h:78
struct bPathCompare * next