aboutsummaryrefslogtreecommitdiff
path: root/dir.h
diff options
context:
space:
mode:
authorVictoria Dye <vdye@github.com>2023-10-09 21:58:54 +0000
committerJunio C Hamano <gitster@pobox.com>2023-10-09 15:53:13 -0700
commit6dc10043338bbb29ffd7f8fc431f37b0fed08ae6 (patch)
tree93c140d03d14f0d066b19a5c996892b14a9dafa8 /dir.h
parent5305474ec4650755f2c0437c004cabfb1c60cf6a (diff)
downloadgit-6dc10043338bbb29ffd7f8fc431f37b0fed08ae6.tar.xz
dir.[ch]: expose 'get_dtype'
Move 'get_dtype()' from 'diagnose.c' to 'dir.c' and add its declaration to 'dir.h' so that it is accessible to callers in other files. The function and its documentation are moved verbatim except for a small addition to the description clarifying what the 'path' arg represents. Signed-off-by: Victoria Dye <vdye@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'dir.h')
-rw-r--r--dir.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/dir.h b/dir.h
index ad06682fd5..28c630ce80 100644
--- a/dir.h
+++ b/dir.h
@@ -363,6 +363,17 @@ struct dir_struct {
struct dirent *readdir_skip_dot_and_dotdot(DIR *dirp);
+/*
+ * Get the d_type of a dirent. If the d_type is unknown, derive it from
+ * stat.st_mode using the path to the dirent's containing directory (path) and
+ * the name of the dirent itself.
+ *
+ * Note that 'path' is assumed to have a trailing slash. It is also modified
+ * in-place during the execution of the function, but is then reverted to its
+ * original value before returning.
+ */
+unsigned char get_dtype(struct dirent *e, struct strbuf *path);
+
/*Count the number of slashes for string s*/
int count_slashes(const char *s);