source src/unix/realpath.c
| Line | Flow | Count | Block(s) | Source |
|---|---|---|---|---|
| 1 | - | /* | ||
| 2 | - | * Copyright (C) the libgit2 contributors. All rights reserved. | ||
| 3 | - | * | ||
| 4 | - | * This file is part of libgit2, distributed under the GNU GPL v2 with | ||
| 5 | - | * a Linking Exception. For full terms see the included COPYING file. | ||
| 6 | - | */ | ||
| 7 | - | |||
| 8 | - | #include "common.h" | ||
| 9 | - | |||
| 10 | - | #include "git2/common.h" | ||
| 11 | - | |||
| 12 | - | #ifndef GIT_WIN32 | ||
| 13 | - | |||
| 14 | - | #include <limits.h> | ||
| 15 | - | #include <stdlib.h> | ||
| 16 | - | #include <fcntl.h> | ||
| 17 | - | #include <unistd.h> | ||
| 18 | - | |||
| 19 | 66415 | 2 | char *p_realpath(const char *pathname, char *resolved) | |
| 20 | - | { | ||
| 21 | - | char *ret; | ||
| 22 | 66442 | 2,3 | if ((ret = realpath(pathname, resolved)) == NULL) | |
| 23 | 1760 | 4 | return NULL; | |
| 24 | - | |||
| 25 | - | #ifdef __OpenBSD__ | ||
| 26 | - | /* The OpenBSD realpath function behaves differently, | ||
| 27 | - | * figure out if the file exists */ | ||
| 28 | - | if (access(ret, F_OK) < 0) | ||
| 29 | - | ret = NULL; | ||
| 30 | - | #endif | ||
| 31 | 64682 | 5 | return ret; | |
| 32 | - | } | ||
| 33 | - | |||
| 34 | - | #endif |