Blame src/unix/realpath.c
|
Packit |
ae9e2a |
/*
|
|
Packit |
ae9e2a |
* Copyright (C) the libgit2 contributors. All rights reserved.
|
|
Packit |
ae9e2a |
*
|
|
Packit |
ae9e2a |
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
|
Packit |
ae9e2a |
* a Linking Exception. For full terms see the included COPYING file.
|
|
Packit |
ae9e2a |
*/
|
|
Packit |
ae9e2a |
#include <git2/common.h>
|
|
Packit |
ae9e2a |
|
|
Packit |
ae9e2a |
#ifndef GIT_WIN32
|
|
Packit |
ae9e2a |
|
|
Packit |
ae9e2a |
#include <limits.h>
|
|
Packit |
ae9e2a |
#include <stdlib.h>
|
|
Packit |
ae9e2a |
#include <fcntl.h>
|
|
Packit |
ae9e2a |
#include <unistd.h>
|
|
Packit |
ae9e2a |
|
|
Packit |
ae9e2a |
char *p_realpath(const char *pathname, char *resolved)
|
|
Packit |
ae9e2a |
{
|
|
Packit |
ae9e2a |
char *ret;
|
|
Packit |
ae9e2a |
if ((ret = realpath(pathname, resolved)) == NULL)
|
|
Packit |
ae9e2a |
return NULL;
|
|
Packit |
ae9e2a |
|
|
Packit |
ae9e2a |
#ifdef __OpenBSD__
|
|
Packit |
ae9e2a |
/* The OpenBSD realpath function behaves differently,
|
|
Packit |
ae9e2a |
* figure out if the file exists */
|
|
Packit |
ae9e2a |
if (access(ret, F_OK) < 0)
|
|
Packit |
ae9e2a |
ret = NULL;
|
|
Packit |
ae9e2a |
#endif
|
|
Packit |
ae9e2a |
return ret;
|
|
Packit |
ae9e2a |
}
|
|
Packit |
ae9e2a |
|
|
Packit |
ae9e2a |
#endif
|