summaryrefslogtreecommitdiff
path: root/src/path.h
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-04-29 11:05:27 -0400
committerEdward Thomson <ethomson@microsoft.com>2015-05-01 12:31:05 -0400
commitedbfc52cdd8657371c53070c5e09b58e004bb67a (patch)
tree08e658ddc002071357397647aa5fa4453e56fe39 /src/path.h
parent544139f50bd7471a62135b29b6a1a2f7c64a1a1c (diff)
downloadlibgit2-edbfc52cdd8657371c53070c5e09b58e004bb67a.tar.gz
git_path: introduce 'git_path_diriter'
Introduce a new `git_path_diriter` that can iterate directories efficiently for each platform.
Diffstat (limited to 'src/path.h')
-rw-r--r--src/path.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/path.h b/src/path.h
index 440b5420c..3a25d4aed 100644
--- a/src/path.h
+++ b/src/path.h
@@ -273,6 +273,7 @@ extern int git_path_apply_relative(git_buf *target, const char *relpath);
enum {
GIT_PATH_DIR_IGNORE_CASE = (1u << 0),
GIT_PATH_DIR_PRECOMPOSE_UNICODE = (1u << 1),
+ GIT_PATH_DIR_INCLUDE_DOT_AND_DOTDOT = (1u << 2),
};
/**
@@ -326,6 +327,37 @@ extern int git_path_walk_up(
int (*callback)(void *payload, const char *path),
void *payload);
+typedef struct git_path_diriter git_path_diriter;
+
+struct git_path_diriter
+{
+ git_buf path;
+ size_t parent_len;
+
+ unsigned int flags;
+
+ DIR *dir;
+};
+
+extern int git_path_diriter_init(
+ git_path_diriter *diriter,
+ const char *path,
+ unsigned int flags);
+
+extern int git_path_diriter_next(
+ const char **out,
+ size_t *out_len,
+ git_path_diriter *diriter);
+
+extern int git_path_diriter_fullpath(
+ const char **out,
+ size_t *out_len,
+ git_path_diriter *diriter);
+
+extern int git_path_diriter_stat(struct stat *out, git_path_diriter *diriter);
+
+extern void git_path_diriter_free(git_path_diriter *diriter);
+
/**
* Load all directory entries (except '.' and '..') into a vector.
*