tstShflCase.cpp revision bdfca6b1ae619c91a5b496beab0dcc41567a4aa4
/** @file
*
* Testcase for shared folder case conversion
*/
/*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <stdio.h>
/* override for linux host */
#define RTPATH_DELIMITER '\\'
#define RTPathQueryInfo rtPathQueryInfo
#define RTDirOpenFiltered rtDirOpenFiltered
#define RTDirClose rtDirClose
#define RTDirReadEx rtDirReadEx
static int iDirList = 0;
static int iDirFile = 0;
static const char *pszDirList[] =
{
"c:",
"c:\\test dir",
"c:\\test dir\\SUBDIR",
};
static const char *pszDirListC[] =
{
".",
"..",
"test dir"
};
static const char *pszDirListTestdir[] =
{
".",
"..",
"SUBDIR",
"a.bat",
"aTestJe.bat",
"aTestje.bat",
"b.bat",
"c.bat",
"d.bat",
"e.bat",
"f.bat",
"g.bat",
"h.bat",
"x.bat",
"z.bat",
};
static const char *pszDirListSUBDIR[] =
{
".",
"..",
"a.bat",
"aTestJe.bat",
"aTestje.bat",
"b.bat",
"c.bat",
"d.bat",
"e.bat",
"f.bat",
"g.bat",
"h.bat",
"x.bat",
"z.bat",
};
{
iDirList = 1;
else
iDirList = 2;
else
iDirList = 3;
else
AssertFailed();
return VINF_SUCCESS;
}
{
iDirFile = 0;
return VINF_SUCCESS;
}
int rtDirReadEx(PRTDIR pDir, PRTDIRENTRYEX pDirEntry, size_t *pcbDirEntry, RTFSOBJATTRADD enmAdditionalAttribs)
{
switch(iDirList)
{
case 1:
return VERR_NO_MORE_FILES;
break;
case 2:
return VERR_NO_MORE_FILES;
break;
case 3:
return VERR_NO_MORE_FILES;
break;
}
return VINF_SUCCESS;
}
int rtPathQueryInfo(const char *pszPath, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAdditionalAttribs)
{
int cMax;
const char **ppszDirList;
/* first try pszDirList */
for (unsigned int i=0;i<RT_ELEMENTS(pszDirList);i++)
{
return VINF_SUCCESS;
}
switch(iDirList)
{
case 1:
break;
case 2:
break;
case 3:
break;
default:
return VERR_FILE_NOT_FOUND;
}
for (int i=0;i<cMax;i++)
{
return VINF_SUCCESS;
}
return VERR_FILE_NOT_FOUND;
}
{
int rc = VERR_FILE_NOT_FOUND;
char szWildCard[4];
cbDirEntry = 4096;
if (pDirEntry == 0)
{
AssertFailed();
return VERR_NO_MEMORY;
}
/** @todo this is quite inefficient, especially for directories with many files */
*(pszStartComponent-1) = 0;
szWildCard[0] = RTPATH_DELIMITER;
szWildCard[2] = 0;
if (RT_FAILURE(rc))
goto end;
for(;;)
{
if (rc == VERR_NO_MORE_FILES)
break;
{
AssertFailed();
if (rc != VERR_NO_TRANSLATION)
break;
else
continue;
}
{
rc = VINF_SUCCESS;
break;
}
}
if (RT_FAILURE(rc))
end:
if (pDirEntry)
if (hSearch)
return rc;
}
{
int rc;
char *pszWildCardComponent = NULL;
if (fWildCard)
{
/* strip off the last path component, that contains the wildcard(s) */
while(src > pszFullPath)
{
if (*src == RTPATH_DELIMITER)
break;
src--;
}
if (*src == RTPATH_DELIMITER)
{
bool fHaveWildcards = false;
while(*temp)
{
/** @todo should depend on the guest OS */
{
fHaveWildcards = true;
break;
}
temp++;
}
if (fHaveWildcards)
{
*pszWildCardComponent = 0;
}
}
}
{
/* Find partial path that's valid */
while(src > pszFullPath)
{
if (*src == RTPATH_DELIMITER)
{
*src = 0;
*src = RTPATH_DELIMITER;
if (rc == VINF_SUCCESS)
{
#ifdef DEBUG
*src = 0;
*src = RTPATH_DELIMITER;
#endif
break;
}
}
src--;
}
if ( *src == RTPATH_DELIMITER
&& RT_SUCCESS(rc))
{
src++;
for(;;)
{
bool fEndOfString = true;
while(*end)
{
if (*end == RTPATH_DELIMITER)
break;
end++;
}
if (*end == RTPATH_DELIMITER)
{
fEndOfString = false;
*end = 0;
}
else
else
{
/* path component is invalid; try to correct the casing */
if (RT_FAILURE(rc))
{
if (!fEndOfString)
*end = RTPATH_DELIMITER;
break;
}
}
if (fEndOfString)
break;
*end = RTPATH_DELIMITER;
}
if (RT_FAILURE(rc))
}
else
}
if (pszWildCardComponent)
if (RT_SUCCESS(rc))
else
return rc;
}
{
char szTest[128];
return 0;
}