symlink-posix.cpp revision c58f1213e628a545081c70e26c6b67a841cff880
/* $Id$ */
/** @file
* IPRT - Symbolic Links, POSIX.
*/
/*
* Copyright (C) 2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP RTLOGGROUP_SYMLINK
#include <errno.h>
#include <unistd.h>
{
bool fRc = false;
char const *pszNativeSymlink;
if (RT_SUCCESS(rc))
{
struct stat s;
}
return fRc;
}
{
bool fRc = false;
char const *pszNativeSymlink;
if (RT_SUCCESS(rc))
{
struct stat s;
if (fRc)
{
errno = 0;
}
}
return fRc;
}
RTDECL(int) RTSymlinkCreate(const char *pszSymlink, const char *pszTarget, RTSYMLINKTYPE enmType, uint32_t fCreate)
{
/*
* Validate the input.
*/
AssertReturn(enmType > RTSYMLINKTYPE_INVALID && enmType < RTSYMLINKTYPE_END, VERR_INVALID_PARAMETER);
/*
* Convert the paths.
*/
char const *pszNativeSymlink;
if (RT_SUCCESS(rc))
{
const char *pszNativeTarget;
if (RT_SUCCESS(rc))
{
/*
* Create the link.
*/
rc = VINF_SUCCESS;
else
}
}
LogFlow(("RTSymlinkCreate(%p={%s}, %p={%s}, %d, %#x): returns %Rrc\n", pszSymlink, pszSymlink, pszTarget, pszTarget, enmType, fCreate, rc));
return rc;
}
{
char const *pszNativeSymlink;
if (RT_SUCCESS(rc))
{
struct stat s;
if (!lstat(pszNativeSymlink, &s))
{
{
if (unlink(pszNativeSymlink) == 0)
rc = VINF_SUCCESS;
else
}
else
}
else
}
return rc;
}
{
char *pszMyTarget;
if (RT_SUCCESS(rc))
{
}
return rc;
}
{
char const *pszNativeSymlink;
if (RT_SUCCESS(rc))
{
/* Guess the initial buffer size. */
struct stat s;
if (!lstat(pszNativeSymlink, &s))
else
cbBuf = 1024;
/* Read loop that grows the buffer. */
for (;;)
{
if (pszBuf)
{
if (cbReturned >= cbBuf)
{
/* Increase the buffer size and try again */
cbBuf *= 2;
continue;
}
if (cbReturned > 0)
{
}
else
}
else
break;
} /* for loop */
}
if (RT_SUCCESS(rc))
LogFlow(("RTSymlinkReadA(%p={%s},%p): returns %Rrc *ppszTarget=%p:{%s}\n", pszSymlink, pszSymlink, ppszTarget, rc, *ppszTarget, *ppszTarget));
else
return rc;
}