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 
8 #ifndef INCLUDE_sys_git_path_h__
9 #define INCLUDE_sys_git_path_h__
10 
11 #include "git2/common.h"
12 
13 GIT_BEGIN_DECL
14 
15 /**
16  * The kinds of git-specific files we know about.
17  *
18  * The order needs to stay the same to not break the `gitfiles`
19  * array in path.c
20  */
21 typedef enum {
22 	/** Check for the .gitignore file */
23 	GIT_PATH_GITFILE_GITIGNORE,
24 	/** Check for the .gitmodules file */
25 	GIT_PATH_GITFILE_GITMODULES,
26 	/** Check for the .gitattributes file */
27 	GIT_PATH_GITFILE_GITATTRIBUTES
28 } git_path_gitfile;
29 
30 /**
31  * The kinds of checks to perform according to which filesystem we are trying to
32  * protect.
33  */
34 typedef enum {
35 	/** Do both NTFS- and HFS-specific checks */
36 	GIT_PATH_FS_GENERIC,
37 	/** Do NTFS-specific checks only */
38 	GIT_PATH_FS_NTFS,
39 	/** Do HFS-specific checks only */
40 	GIT_PATH_FS_HFS
41 } git_path_fs;
42 
43 /**
44  * Check whether a path component corresponds to a .git$SUFFIX
45  * file.
46  *
47  * As some filesystems do special things to filenames when
48  * writing files to disk, you cannot always do a plain string
49  * comparison to verify whether a file name matches an expected
50  * path or not. This function can do the comparison for you,
51  * depending on the filesystem you're on.
52  *
53  * @param path the path component to check
54  * @param pathlen the length of `path` that is to be checked
55  * @param gitfile which file to check against
56  * @param fs which filesystem-specific checks to use
57  * @return 0 in case the file does not match, a positive value if
58  *         it does; -1 in case of an error
59  */
60 GIT_EXTERN(int) git_path_is_gitfile(const char *path, size_t pathlen, git_path_gitfile gitfile, git_path_fs fs);
61 
62 GIT_END_DECL
63 
64 #endif	/* INCLUDE_sys_git_path */
65