mirror of
https://git.proxmox.com/git/libgit2
synced 2025-06-28 05:14:44 +00:00
Fix gitfo_isdir() in Win32 systems
Because adhering to the POSIX standards is overrated. Signed-off-by: Vicent Marti <tanoku@gmail.com>
This commit is contained in:
parent
6b1eab3976
commit
43e380a88c
@ -56,7 +56,25 @@ int gitfo_write(git_file fd, void *buf, size_t cnt)
|
||||
int gitfo_isdir(const char *path)
|
||||
{
|
||||
struct stat st;
|
||||
return (path && gitfo_stat(path, &st) == 0 && S_ISDIR(st.st_mode)) ?
|
||||
int len, stat_error;
|
||||
|
||||
if (!path)
|
||||
return GIT_ENOTFOUND;
|
||||
|
||||
len = strlen(path);
|
||||
|
||||
/* win32: stat path for folders cannot end in a slash */
|
||||
if (path[len - 1] == '/') {
|
||||
char *path_fixed = NULL;
|
||||
path_fixed = git__strdup(path);
|
||||
path_fixed[len - 1] = 0;
|
||||
stat_error = gitfo_stat(path_fixed, &st);
|
||||
free(path_fixed);
|
||||
} else {
|
||||
stat_error = gitfo_stat(path, &st);
|
||||
}
|
||||
|
||||
return (stat_error == 0 && S_ISDIR(st.st_mode)) ?
|
||||
GIT_SUCCESS : GIT_ENOTFOUND;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user