本文整理汇总了C++中PathCharString::Reserve方法的典型用法代码示例。如果您正苦于以下问题:C++ PathCharString::Reserve方法的具体用法?C++ PathCharString::Reserve怎么用?C++ PathCharString::Reserve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PathCharString
的用法示例。
在下文中一共展示了PathCharString::Reserve方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ENTRY
/*++
Function:
CreateDirectoryA
Note:
lpSecurityAttributes always NULL.
See MSDN doc.
--*/
BOOL
PALAPI
CreateDirectoryA(
IN LPCSTR lpPathName,
IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
{
BOOL bRet = FALSE;
DWORD dwLastError = 0;
PathCharString realPath;
char* realPathBuf;
LPSTR unixPathName = NULL;
int pathLength;
int i;
const int mode = S_IRWXU | S_IRWXG | S_IRWXO;
PERF_ENTRY(CreateDirectoryA);
ENTRY("CreateDirectoryA(lpPathName=%p (%s), lpSecurityAttr=%p)\n",
lpPathName?lpPathName:"NULL",
lpPathName?lpPathName:"NULL", lpSecurityAttributes);
if ( lpSecurityAttributes )
{
ASSERT("lpSecurityAttributes is not NULL as it should be\n");
dwLastError = ERROR_INVALID_PARAMETER;
goto done;
}
// Windows returns ERROR_PATH_NOT_FOUND when called with NULL.
// If we don't have this check, strdup(NULL) segfaults.
if (lpPathName == NULL)
{
ERROR("CreateDirectoryA called with NULL pathname!\n");
dwLastError = ERROR_PATH_NOT_FOUND;
goto done;
}
unixPathName = PAL__strdup(lpPathName);
if (unixPathName == NULL )
{
ERROR("PAL__strdup() failed\n");
dwLastError = ERROR_NOT_ENOUGH_MEMORY;
goto done;
}
FILEDosToUnixPathA( unixPathName );
// Remove any trailing slashes at the end because mkdir might not
// handle them appropriately on all platforms.
pathLength = strlen(unixPathName);
i = pathLength;
while(i > 1)
{
if(unixPathName[i - 1] =='/')
{
unixPathName[i - 1]='\0';
i--;
}
else
{
break;
}
}
// Get an absolute path.
if (unixPathName[0] == '/')
{
realPathBuf = unixPathName;
}
else
{
DWORD len = GetCurrentDirectoryA(realPath);
if (len == 0 || !realPath.Reserve(realPath.GetCount() + pathLength + 1 ))
{
dwLastError = DIRGetLastErrorFromErrno();
WARN("Getcwd failed with errno=%d \n", dwLastError);
goto done;
}
realPath.Append("/", 1);
realPath.Append(unixPathName, pathLength);
realPathBuf = realPath.OpenStringBuffer(realPath.GetCount());
}
// Canonicalize the path so we can determine its length.
FILECanonicalizePath(realPathBuf);
if ( mkdir(realPathBuf, mode) != 0 )
{
TRACE("Creation of directory [%s] was unsuccessful, errno = %d.\n",
unixPathName, errno);
//.........这里部分代码省略.........