Blame src/unix/realpath.c

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