robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

taorefactor(path): pathcmp() #41035f0a0182285

master
2.3 KiB60 linesraw
1#pragma once
2
3#include <stddef.h>  // IWYU pragma: keep
4
5#include "nvim/api/private/defs.h"  // IWYU pragma: keep
6#include "nvim/garray_defs.h"  // IWYU pragma: keep
7#include "nvim/types_defs.h"  // IWYU pragma: keep
8
9/// Flags for expand_wildcards()
10enum {
11  EW_DIR        = 0x01,     ///< include directory names
12  EW_FILE       = 0x02,     ///< include file names
13  EW_NOTFOUND   = 0x04,     ///< include not found names
14  EW_ADDSLASH   = 0x08,     ///< append slash to directory name
15  EW_KEEPALL    = 0x10,     ///< keep all matches
16  EW_SILENT     = 0x20,     ///< don't print "1 returned" from shell
17  EW_EXEC       = 0x40,     ///< executable files
18  EW_PATH       = 0x80,     ///< search in 'path' too
19  EW_ICASE      = 0x100,    ///< ignore case
20  EW_NOERROR    = 0x200,    ///< no error for bad regexp
21  EW_NOTWILD    = 0x400,    ///< add match with literal name if exists
22  EW_KEEPDOLLAR = 0x800,    ///< do not escape $, $var is expanded
23  EW_ALLLINKS   = 0x1000,   ///< also links not pointing to existing file
24  EW_SHELLCMD   = 0x2000,   ///< called from expand_shellcmd(), don't check
25                            ///< if executable is in $PATH
26  EW_DODOT      = 0x4000,   ///< also files starting with a dot
27  EW_EMPTYOK    = 0x8000,   ///< no matches is not an error
28  EW_NOTENV     = 0x10000,  ///< do not expand environment variables
29  EW_CDPATH     = 0x20000,  ///< search in 'cdpath' too
30  EW_NOBREAK    = 0x40000,  ///< do not invoke breakcheck
31};
32// Note: mostly EW_NOTFOUND and EW_SILENT are mutually exclusive: EW_NOTFOUND
33// is used when executing commands and EW_SILENT for interactive expanding.
34
35/// path_equal() flags
36typedef enum {
37  kPathCmpLiteral = 1 << 0,  ///< Compare paths literally.
38  kPathCmpExpand  = 1 << 1,  ///< Expand env vars in the first path.
39  kPathCmpFull    = 1 << 2,  ///< Compare full names when FileIds are unavailable.
40} PathCmpFlags;
41
42#ifdef BACKSLASH_IN_FILENAME
43# define TO_SLASH(p) path_to_slash(p)
44# define TO_SLASH_SAVE(p) path_to_slash_save(p)
45# define TO_BACKSLASH(p) path_to_backslash(p)
46#else
47# define TO_SLASH(...)
48# define TO_SLASH_SAVE(p) xstrdup(p)
49# define TO_BACKSLASH(...)
50#endif
51
52#ifdef MSWIN
53# define PATH_ESC_WILDCARDS "*?["
54# define PATH_ALL_WILDCARDS "*?[`$"
55#else
56# define PATH_ESC_WILDCARDS "*?[{"
57# define PATH_ALL_WILDCARDS "*?[{`'$"
58#endif
59
60#include "path.h.generated.h"