summaryrefslogtreecommitdiffstats
path: root/src/util/fs_path.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-21 05:03:04 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-21 05:03:04 +0000
commit3b8d76c14c6a5f32d1f23f7e952dc4d859d75e9f (patch)
tree773f780ce433e99a5e25775d640778aa8b50d829 /src/util/fs_path.h
parentAdding debian version 1.7.2+ds-1. (diff)
downloadlibgit2-3b8d76c14c6a5f32d1f23f7e952dc4d859d75e9f.tar.xz
libgit2-3b8d76c14c6a5f32d1f23f7e952dc4d859d75e9f.zip
Merging upstream version 1.8.1+ds.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/util/fs_path.h')
-rw-r--r--src/util/fs_path.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/util/fs_path.h b/src/util/fs_path.h
index e5ca673..43f7951 100644
--- a/src/util/fs_path.h
+++ b/src/util/fs_path.h
@@ -87,6 +87,29 @@ extern int git_fs_path_to_dir(git_str *path);
extern void git_fs_path_string_to_dir(char *path, size_t size);
/**
+ * Provides the length of the given path string with no trailing
+ * slashes.
+ */
+size_t git_fs_path_dirlen(const char *path);
+
+/**
+ * Returns nonzero if the given path is a filesystem root; on Windows, this
+ * means a drive letter (eg `A:/`, `C:\`). On POSIX this is `/`.
+ */
+GIT_INLINE(int) git_fs_path_is_root(const char *name)
+{
+#ifdef GIT_WIN32
+ if (((name[0] >= 'A' && name[0] <= 'Z') || (name[0] >= 'a' && name[0] <= 'z')) &&
+ name[1] == ':' &&
+ (name[2] == '/' || name[2] == '\\') &&
+ name[3] == '\0')
+ return 1;
+#endif
+
+ return (name[0] == '/' && name[1] == '\0');
+}
+
+/**
* Taken from git.git; returns nonzero if the given path is "." or "..".
*/
GIT_INLINE(int) git_fs_path_is_dot_or_dotdot(const char *name)