RTPathParse.cpp.h revision c5ed12eaa2298c6cd7f84f548a8540e09f4705b1
/* $Id$ */
/** @file
* IPRT - RTPathParse - Code Template.
*
* This file included multiple times with different path style macros.
*/
/*
* Copyright (C) 2006-2013 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.
*/
/**
* @copydoc RTPathParse
*/
static int RTPATH_STYLE_FN(rtPathParse)(const char *pszPath, PRTPATHPARSED pParsed, size_t cbParsed, uint32_t fFlags)
{
/*
* Parse the root specification if present and initialize the parser state
* (keep it on the stack for speed).
*/
: 0xfff0;
if (RTPATH_IS_SLASH(pszPath[0]))
{
if (fFlags & RTPATH_STR_F_NO_START)
{
offCur = 1;
offCur++;
return VERR_PATH_ZERO_LENGTH;
cchPath = 0;
}
&& pszPath[2])
{
/* UNC - skip to the end of the potential namespace or computer name. */
offCur = 2;
offCur++;
/* If there is another slash, we considered it a valid UNC path, if
not it's just a root path with an extra slash thrown in. */
{
offCur++;
}
else
{
offCur = 1;
cchPath = 1;
}
}
#endif
else
{
#else
#endif
offCur = 1;
cchPath = 1;
}
}
{
{
offCur = 2;
}
else
{
offCur = 3;
}
}
#endif
else
{
offCur = 0;
cchPath = 0;
}
/* Add it to the component array . */
{
{
}
idxComp++;
/* Skip unnecessary slashes following the root-spec. */
{
do
offCur++;
}
}
/*
* Parse the rest.
*/
{
for (;;)
{
/* Find the end of the component. */
char ch;
offCur++;
return VERR_FILENAME_TOO_LONG;
/* Add it. */
{
}
idxComp++;
/* Look for '.' and '..' references. */
{
}
/* Skip unnecessary slashes. Leave ch unchanged! */
if (ch2)
{
if (RTPATH_IS_SLASH(ch2))
{
do
while (RTPATH_IS_SLASH(ch2));
}
}
/* The end? */
if (ch2 == '\0')
{
if (ch)
{
if (!(fFlags & RTPATH_STR_F_NO_END))
{
cchPath++;
}
else
}
else if (!(fFlags & RTPATH_STR_F_NO_END))
{
/* look for an ? */
{
{
}
break;
}
}
break;
}
/* No, not the end. Account for an separator before we restart the loop. */
}
}
else
{
}
return VERR_FILENAME_TOO_LONG;
/*
* Store the remainder of the state and we're done.
*/
}