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