Commit e190da78 by schu

fileops: add convenience function is_dot_or_dotdot()

Signed-off-by: schu <schu-github@schulog.org>
parent a6e0f315
...@@ -231,13 +231,8 @@ int git_futils_direach( ...@@ -231,13 +231,8 @@ int git_futils_direach(
size_t de_len; size_t de_len;
int result; int result;
/* always skip '.' and '..' */ if (is_dot_or_dotdot(de->d_name))
if (de->d_name[0] == '.') { continue;
if (de->d_name[1] == '\0')
continue;
if (de->d_name[1] == '.' && de->d_name[2] == '\0')
continue;
}
de_len = strlen(de->d_name); de_len = strlen(de->d_name);
if (path_sz < wd_len + de_len + 1) { if (path_sz < wd_len + de_len + 1) {
......
...@@ -102,6 +102,14 @@ extern int git_futils_mv_withpath(const char *from, const char *to); ...@@ -102,6 +102,14 @@ extern int git_futils_mv_withpath(const char *from, const char *to);
*/ */
extern git_off_t git_futils_filesize(git_file fd); extern git_off_t git_futils_filesize(git_file fd);
/* Taken from git.git */
static inline int is_dot_or_dotdot(const char *name)
{
return (name[0] == '.' &&
(name[1] == '\0' ||
(name[1] == '.' && name[2] == '\0')));
}
/** /**
* Read-only map all or part of a file into memory. * Read-only map all or part of a file into memory.
* When possible this function should favor a virtual memory * When possible this function should favor a virtual memory
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment