symlink-win.cpp revision c9579522f347fc3fda6b3f4add0b355981cd7758
/* $Id$ */
/** @file
* IPRT - Symbolic Links, Windows.
*/
/*
* Copyright (C) 2010 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
{
bool fRc = false;
if (RT_SUCCESS(rc))
return fRc;
}
{
bool fRc = false;
if (RT_SUCCESS(rc))
{
if (fRc)
{
}
}
return fRc;
}
{
/*
* Validate the input.
*/
AssertReturn(enmType > RTSYMLINKTYPE_INVALID && enmType < RTSYMLINKTYPE_END, VERR_INVALID_PARAMETER);
/*
* Resolve the API.
*/
if (!s_fTried)
{
if (hmod)
{
if (pfn)
}
s_fTried = true;
}
if (!s_pfnCreateSymbolicLinkW)
{
LogFlow(("RTSymlinkCreate(%p={%s}, %p={%s}, %d): returns VERR_NOT_SUPPORTED - Windows API not found\n",
return VERR_NOT_SUPPORTED;
}
/*
* Convert the paths.
*/
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
/*
* Massage the target path, determin the link type.
*/
{
while ( offFromEnd < cchTarget
{
offFromEnd++;
}
}
if (enmType == RTSYMLINKTYPE_UNKNOWN)
{
if ( cchTarget > cchVolSpecTarget
else if (cchVolSpecTarget)
{
if ( dwAttr != INVALID_FILE_ATTRIBUTES
&& (dwAttr & FILE_ATTRIBUTE_DIRECTORY))
}
else
{
/** @todo Join the symlink directory with the target and
* look up the attributes on that. -lazy bird. */
}
}
/*
* Create the link.
*/
rc = VINF_SUCCESS;
else
}
}
LogFlow(("RTSymlinkCreate(%p={%s}, %p={%s}, %d): returns %Rrc\n", pszSymlink, pszSymlink, pszTarget, pszTarget, enmType, rc));
return rc;
}
{
/*
* Convert the path.
*/
if (RT_SUCCESS(rc))
{
/*
* We have to use different APIs depending on whether this is a
* directory or file link. This means we're subject to one more race
* than on posix at the moment. We could probably avoid this though,
* if we wanted to go talk with the native API layer below Win32...
*/
if (dwAttr != INVALID_FILE_ATTRIBUTES)
{
{
if (dwAttr & FILE_ATTRIBUTE_DIRECTORY)
else
if (fRc)
rc = VINF_SUCCESS;
else
}
else
}
else
}
return rc;
}
{
char *pszMyTarget;
if (RT_SUCCESS(rc))
{
}
return rc;
}
{
if (RT_SUCCESS(rc))
{
NULL,
NULL);
if (hSymlink != INVALID_HANDLE_VALUE)
{
/** @todo what do we do next? FSCTL_GET_REPARSE_POINT? */
}
else
}
if (RT_SUCCESS(rc))
LogFlow(("RTSymlinkReadA(%p={%s},%p): returns %Rrc *ppszTarget=%p:{%s}\n", pszSymlink, pszSymlink, ppszTarget, rc, *ppszTarget, *ppszTarget));
else
return rc;
}