Blender V5.0
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
11
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
20#ifdef WIN32
21# include "BLI_string.h"
22#endif
23
24#include "BKE_autoexec.hh" /* own include */
25
26bool BKE_autoexec_match(const char *path)
27{
28 bPathCompare *path_cmp;
29
30#ifdef WIN32
31 const int fnmatch_flags = FNM_CASEFOLD;
32#else
33 const int fnmatch_flags = 0;
34#endif
35
37
38 for (path_cmp = static_cast<bPathCompare *>(U.autoexec_paths.first); path_cmp;
39 path_cmp = path_cmp->next)
40 {
41 if (path_cmp->path[0] == '\0') {
42 /* pass */
43 }
44 else if (path_cmp->flag & USER_PATHCMP_GLOB) {
45 if (fnmatch(path_cmp->path, path, fnmatch_flags) == 0) {
46 return true;
47 }
48 }
49 else if (BLI_path_ncmp(path_cmp->path, path, strlen(path_cmp->path)) == 0) {
50 return true;
51 }
52 }
53
54 return false;
55}
#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.cc:26
#define U
struct bPathCompare * next