diff options
| author | Romain Geissler <romain.geissler@gmail.com> | 2011-06-03 21:09:14 +0200 |
|---|---|---|
| committer | Romain Geissler <romain.geissler@gmail.com> | 2011-06-03 21:20:20 +0200 |
| commit | bc6484912ebb3db2ac9637abebdeadd28f6d84c3 (patch) | |
| tree | de8619e9387bec1b239b13cb70a7a5ceb20ff264 /src/fileops.c | |
| parent | 26a98ec8a2ebd6d54ad12466552442fde1c6a9d0 (diff) | |
| download | libgit2-bc6484912ebb3db2ac9637abebdeadd28f6d84c3.tar.gz | |
Fileops: Added gitfo_isfile.
Conflicts:
src/fileops.c
Diffstat (limited to 'src/fileops.c')
| -rw-r--r-- | src/fileops.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/fileops.c b/src/fileops.c index 409d1cb5a..11634c263 100644 --- a/src/fileops.c +++ b/src/fileops.c @@ -131,7 +131,26 @@ int gitfo_isdir(const char *path) return git__throw(GIT_ENOTFOUND, "%s does not exist", path); if (!S_ISDIR(st.st_mode)) - return git__throw(GIT_ENOTFOUND, "%s is a file", path); + return git__throw(GIT_ENOTFOUND, "%s is not a directory", path); + + return GIT_SUCCESS; +} + +int gitfo_isfile(const char *path) +{ + struct stat st; + int stat_error; + + if (!path) + return git__throw(GIT_ENOTFOUND, "No path given to gitfo_isfile"); + + stat_error = gitfo_stat(path, &st); + + if (stat_error < GIT_SUCCESS) + return git__throw(GIT_ENOTFOUND, "%s does not exist", path); + + if (!S_ISREG(st.st_mode)) + return git__throw(GIT_ENOTFOUND, "%s is not a file", path); return GIT_SUCCESS; } |
