summaryrefslogtreecommitdiff
path: root/src/path.h
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2017-05-24 11:07:20 +0200
committerPatrick Steinhardt <ps@pks.im>2017-10-09 11:19:41 +0200
commite54cf1a3eed8f2375b9e5d4dac9bf4ded57bdd01 (patch)
tree070deff74a847db50edf4d9b6157bf1a80353079 /src/path.h
parent38e769cb22bd1dda0ae96c14e375f524d4fc47c3 (diff)
downloadlibgit2-e54cf1a3eed8f2375b9e5d4dac9bf4ded57bdd01.tar.gz
path: expose `git_path_is_absolute`
This function has previously been implemented in Windows-specific path handling code as `path__is_absolute`. As we will need this functionality in other parts, extract the logic into "path.h" alongside with a non-Windows implementation.
Diffstat (limited to 'src/path.h')
-rw-r--r--src/path.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/path.h b/src/path.h
index 360372cfb..d674b1b94 100644
--- a/src/path.h
+++ b/src/path.h
@@ -105,6 +105,9 @@ GIT_INLINE(int) git_path_is_dot_or_dotdotW(const wchar_t *name)
(name[1] == L'.' && name[2] == L'\0')));
}
+#define git_path_is_absolute(p) \
+ (git__isalpha((p)[0]) && (p)[1] == ':' && ((p)[2] == '\\' || (p)[2] == '/'))
+
/**
* Convert backslashes in path to forward slashes.
*/
@@ -119,6 +122,10 @@ GIT_INLINE(void) git_path_mkposix(char *path)
}
#else
# define git_path_mkposix(p) /* blank */
+
+#define git_path_is_absolute(p) \
+ ((p)[0] == '/')
+
#endif
/**