1 /*
2  * Copyright (C) the libgit2 contributors. All rights reserved.
3  *
4  * This file is part of libgit2, distributed under the GNU GPL v2 with
5  * a Linking Exception. For full terms see the included COPYING file.
6  */
7 module libgit2_d.sys.path;
8 
9 
10 extern (C):
11 nothrow @nogc:
12 package(libgit2_d):
13 
14 /**
15  * The kinds of git-specific files we know about.
16  *
17  * The order needs to stay the same to not break the `gitfiles`
18  * array in path.c
19  */
20 enum git_path_gitfile
21 {
22 	/**
23 	 * Check for the .gitignore file
24 	 */
25 	GIT_PATH_GITFILE_GITIGNORE,
26 
27 	/**
28 	 * Check for the .gitmodules file
29 	 */
30 	GIT_PATH_GITFILE_GITMODULES,
31 
32 	/**
33 	 * Check for the .gitattributes file
34 	 */
35 	GIT_PATH_GITFILE_GITATTRIBUTES,
36 }
37 
38 //Declaration name in C language
39 enum
40 {
41 	GIT_PATH_GITFILE_GITIGNORE = .git_path_gitfile.GIT_PATH_GITFILE_GITIGNORE,
42 	GIT_PATH_GITFILE_GITMODULES = .git_path_gitfile.GIT_PATH_GITFILE_GITMODULES,
43 	GIT_PATH_GITFILE_GITATTRIBUTES = .git_path_gitfile.GIT_PATH_GITFILE_GITATTRIBUTES,
44 }
45 
46 /**
47  * The kinds of checks to perform according to which filesystem we are trying to
48  * protect.
49  */
50 enum git_path_fs
51 {
52 	/**
53 	 * Do both NTFS- and HFS-specific checks
54 	 */
55 	GIT_PATH_FS_GENERIC,
56 
57 	/**
58 	 * Do NTFS-specific checks only
59 	 */
60 	GIT_PATH_FS_NTFS,
61 
62 	/**
63 	 * Do HFS-specific checks only
64 	 */
65 	GIT_PATH_FS_HFS,
66 }
67 
68 //Declaration name in C language
69 enum
70 {
71 	GIT_PATH_FS_GENERIC = .git_path_fs.GIT_PATH_FS_GENERIC,
72 	GIT_PATH_FS_NTFS = .git_path_fs.GIT_PATH_FS_NTFS,
73 	GIT_PATH_FS_HFS = .git_path_fs.GIT_PATH_FS_HFS,
74 }
75 
76 /**
77  * Check whether a path component corresponds to a .git$SUFFIX
78  * file.
79  *
80  * As some filesystems do special things to filenames when
81  * writing files to disk, you cannot always do a plain string
82  * comparison to verify whether a file name matches an expected
83  * path or not. This function can do the comparison for you,
84  * depending on the filesystem you're on.
85  *
86  * Params:
87  *      path = the path component to check
88  *      pathlen = the length of `path` that is to be checked
89  *      gitfile = which file to check against
90  *      fs = which filesystem-specific checks to use
91  *
92  * Returns: 0 in case the file does not match, a positive value if it does; -1 in case of an error
93  */
94 //GIT_EXTERN
95 int git_path_is_gitfile(const (char)* path, size_t pathlen, .git_path_gitfile gitfile, .git_path_fs fs);