summaryrefslogtreecommitdiff
path: root/src/fileops.h
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2011-01-19 17:15:02 -0800
committerVicent Marti <tanoku@gmail.com>2011-01-19 17:18:01 -0800
commitb5e567b9fcaa9bed476feb79b2c934ddab05e2b9 (patch)
treebeb63a127d36509a56258419804a2457a252aede /src/fileops.h
parentec3c7a16c260fa6540cfe8daf37c1324100f51bf (diff)
parent170d3f2fbbaf529afc209f78fc7ee88b5680eb5d (diff)
downloadlibgit2-b5e567b9fcaa9bed476feb79b2c934ddab05e2b9.tar.gz
Merge branch 'dir-path-prettifying' of https://github.com/nulltoken/libgit2
Diffstat (limited to 'src/fileops.h')
-rw-r--r--src/fileops.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/fileops.h b/src/fileops.h
index fa446e36a..d562dc7ed 100644
--- a/src/fileops.h
+++ b/src/fileops.h
@@ -131,4 +131,28 @@ extern int gitfo_write_cached(gitfo_cache *ioc, void *buf, size_t len);
extern int gitfo_flush_cached(gitfo_cache *ioc);
extern int gitfo_close_cached(gitfo_cache *ioc);
+/**
+ * Clean up a provided absolute or relative directory path.
+ *
+ * This prettification relies on basic operations such as coalescing
+ * multiple forward slashes into a single slash, removing '.' and
+ * './' current directory segments, and removing parent directory
+ * whenever '..' is encountered.
+ *
+ * If not empty, the returned path ends with a forward slash.
+ *
+ * For instance, this will turn "d1/s1///s2/..//../s3" into "d1/s3/".
+ *
+ * This only performs a string based analysis of the path.
+ * No checks are done to make sure the path actually makes sense from
+ * the file system perspective.
+ *
+ * @param buffer_out buffer to populate with the normalized path.
+ * @param path directory path to clean up.
+ * @return
+ * - GIT_SUCCESS on success;
+ * - GIT_ERROR when the input path is invalid or escapes the current directory.
+ */
+GIT_EXTERN(int) git_prettify_dir_path(char *buffer_out, const char *path);
+
#endif /* INCLUDE_fileops_h__ */