summaryrefslogtreecommitdiff
path: root/src/git/fileops.h
diff options
context:
space:
mode:
authorAndreas Ericsson <ae@op5.se>2008-11-29 15:34:20 +0100
committerShawn O. Pearce <spearce@spearce.org>2008-12-02 09:18:19 -0800
commitea790f337b0e401f5e4acabf9af9c2bc756d5f3b (patch)
tree8ec389978cc56e25a6a5bdf6be993c7664e762b5 /src/git/fileops.h
parent4188d28f1c38240392d896fc79561cc461fb12c0 (diff)
downloadlibgit2-ea790f337b0e401f5e4acabf9af9c2bc756d5f3b.tar.gz
Add a dirent walker to the fileops API
Since at least MS have something like GetFirstDirEnt() and GetNextDirEnt() (presumably with superior performance), we can let MS hackers add support for a dirent walker using that API instead, while we stick with the posix-style readdir() calls. Signed-off-by: Andreas Ericsson <ae@op5.se> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'src/git/fileops.h')
-rw-r--r--src/git/fileops.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/git/fileops.h b/src/git/fileops.h
new file mode 100644
index 000000000..856017fbf
--- /dev/null
+++ b/src/git/fileops.h
@@ -0,0 +1,32 @@
+#ifndef INCLUDE_git_fileops_h__
+#define INCLUDE_git_fileops_h__
+
+/**
+ * @file git/fileops.h
+ * @brief Git platform agnostic filesystem operations
+ * @defgroup Git gitfiles
+ * @ingroup Git
+ * @{
+ */
+
+#include "common.h"
+GIT_BEGIN_DECL
+/**
+ * For each directory entry (except . and ..), run the function
+ * "fn", passing it "arg" as its first argument and the path to
+ * the entry as the second argument.
+ * @param dir The directory to walk
+ * @param fn The callback function to run for each entry in *dir.
+ * "fn" may return >0 to signal "I'm done. Stop parsing and
+ * return successfully" or <0 to signal an error. All non-zero
+ * return codes cause directory traversal to stop.
+ * @param arg The first argument that will be passed to 'fn'
+ * @return GIT_SUCCESS if all entries were successfully traversed,
+ * otherwise the result of fn.
+ */
+GIT_EXTERN(int) git_foreach_dirent(const char *dir,
+ int (*fn)(void *, const char *), void *arg);
+
+/** @} */
+GIT_END_DECL
+#endif /* INCLUDE_git_fileops_h__ */