本文整理汇总了C++中PathCharString类的典型用法代码示例。如果您正苦于以下问题:C++ PathCharString类的具体用法?C++ PathCharString怎么用?C++ PathCharString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PathCharString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BuildSharedFilesPath
void SharedMemoryHelpers::BuildSharedFilesPath(PathCharString& destination, const char *suffix, int suffixCharCount)
{
_ASSERTE((int)strlen(suffix) == suffixCharCount);
VerifyStringOperation(destination.Set(*gSharedFilesPath));
VerifyStringOperation(destination.Append(suffix, suffixCharCount));
}
示例2: PAL_BindResources
/*++
Function :
PAL_BindResources - bind the resource domain to the path where the coreclr resides
Returns TRUE if it succeeded, FALSE if it failed due to OOM
--*/
BOOL
PALAPI
PAL_BindResources(IN LPCSTR lpDomain)
{
#ifndef __APPLE__
_ASSERTE(g_szCoreCLRPath != NULL);
char * coreCLRDirectoryPath;
PathCharString coreCLRDirectoryPathPS;
int len = strlen(g_szCoreCLRPath);
coreCLRDirectoryPath = coreCLRDirectoryPathPS.OpenStringBuffer(len);
if (NULL == coreCLRDirectoryPath)
{
return FALSE;
}
DWORD size = FILEGetDirectoryFromFullPathA(g_szCoreCLRPath, len, coreCLRDirectoryPath);
coreCLRDirectoryPathPS.CloseBuffer(size);
_ASSERTE(size <= MAX_LONGPATH);
LPCSTR boundPath = bindtextdomain(lpDomain, coreCLRDirectoryPath);
return boundPath != NULL;
#else // __APPLE__
// UNIXTODO: Implement for OSX if necessary
return TRUE;
#endif // __APPLE__
}
示例3: AppendSessionDirectoryName
bool SharedMemoryId::AppendSessionDirectoryName(PathCharString& path) const
{
if (IsSessionScope())
{
return path.Append(SHARED_MEMORY_SESSION_DIRECTORY_NAME_PREFIX) != FALSE
&& SharedMemoryHelpers::AppendUInt32String(path, GetCurrentSessionId());
}
else
{
return path.Append(SHARED_MEMORY_GLOBAL_DIRECTORY_NAME) != FALSE;
}
}
示例4: RemoveDirectoryHelper
static
BOOL
RemoveDirectoryHelper (
PathCharString& lpPathName,
LPDWORD dwLastError
)
{
BOOL bRet = FALSE;
*dwLastError = 0;
FILEDosToUnixPathA( lpPathName );
if ( rmdir(lpPathName) != 0 )
{
TRACE("Removal of directory [%s] was unsuccessful, errno = %d.\n",
lpPathName.GetString(), errno);
switch( errno )
{
case ENOTDIR:
/* FALL THROUGH */
case ENOENT:
{
struct stat stat_data;
if ( stat( lpPathName, &stat_data) == 0 &&
(stat_data.st_mode & S_IFMT) == S_IFREG )
{
/* Not a directory, it is a file. */
*dwLastError = ERROR_DIRECTORY;
}
else
{
FILEGetProperNotFoundError( lpPathName, dwLastError );
}
break;
}
case ENOTEMPTY:
*dwLastError = ERROR_DIR_NOT_EMPTY;
break;
default:
*dwLastError = ERROR_ACCESS_DENIED;
}
}
else {
TRACE("Removal of directory [%s] was successful.\n", lpPathName.GetString());
bRet = TRUE;
}
return bRet;
}
示例5: LoadLibraryExW
/*++
Function:
LoadLibraryExW
See MSDN doc.
--*/
HMODULE
PALAPI
LoadLibraryExW(
IN LPCWSTR lpLibFileName,
IN /*Reserved*/ HANDLE hFile,
IN DWORD dwFlags)
{
if (dwFlags != 0)
{
// UNIXTODO: Implement this!
ASSERT("Needs Implementation!!!");
return nullptr;
}
CHAR * lpstr;
INT name_length;
PathCharString pathstr;
HMODULE hModule = nullptr;
PERF_ENTRY(LoadLibraryExW);
ENTRY("LoadLibraryExW (lpLibFileName=%p (%S)) \n",
lpLibFileName ? lpLibFileName : W16_NULLSTRING,
lpLibFileName ? lpLibFileName : W16_NULLSTRING);
if (!LOADVerifyLibraryPath(lpLibFileName))
{
goto done;
}
lpstr = pathstr.OpenStringBuffer((PAL_wcslen(lpLibFileName)+1) * MaxWCharToAcpLength);
if (nullptr == lpstr)
{
goto done;
}
if (!LOADConvertLibraryPathWideStringToMultibyteString(lpLibFileName, lpstr, &name_length))
{
goto done;
}
/* do the Dos/Unix conversion on our own copy of the name */
FILEDosToUnixPathA(lpstr);
pathstr.CloseBuffer(name_length);
/* let LOADLoadLibrary call SetLastError in case of failure */
hModule = LOADLoadLibrary(lpstr, TRUE);
done:
LOGEXIT("LoadLibraryExW returns HMODULE %p\n", hModule);
PERF_EXIT(LoadLibraryExW);
return hModule;
}
示例6: GetCurrentDirectoryA
/*++
Function:
GetCurrentDirectoryA
--*/
DWORD
GetCurrentDirectoryA(PathCharString& lpBuffer)
{
DWORD dwDirLen = 0;
DWORD dwLastError = 0;
char *current_dir;
PERF_ENTRY(GetCurrentDirectoryA);
ENTRY("GetCurrentDirectoryA(lpBuffer=%p)\n", lpBuffer.GetString());
current_dir = lpBuffer.OpenStringBuffer(MAX_PATH);
/* NULL first arg means getcwd will allocate the string */
current_dir = PAL__getcwd( current_dir, MAX_PATH);
if (current_dir != NULL )
{
dwDirLen = strlen( current_dir );
lpBuffer.CloseBuffer(dwDirLen);
goto done;
}
else if ( errno == ERANGE )
{
lpBuffer.CloseBuffer(0);
current_dir = PAL__getcwd( NULL, 0);
}
if ( !current_dir )
{
WARN("Getcwd failed with errno=%d [%s]\n", errno, strerror(errno));
dwLastError = DIRGetLastErrorFromErrno();
dwDirLen = 0;
goto done;
}
dwDirLen = strlen( current_dir );
lpBuffer.Set(current_dir, dwDirLen);
PAL_free(current_dir);
done:
if ( dwLastError )
{
SetLastError(dwLastError);
}
LOGEXIT("GetCurrentDirectoryA returns DWORD %u\n", dwDirLen);
PERF_EXIT(GetCurrentDirectoryA);
return dwDirLen;
}
示例7: failure
/*
Function:
PAL_RegisterLibraryDirect
Registers a system handle to a loaded library with the module list.
Returns a PAL handle to the loaded library, or nullptr upon failure (error is set via SetLastError()).
*/
HMODULE
PALAPI
PAL_RegisterLibraryDirect(
IN void *dl_handle,
IN LPCWSTR lpLibFileName)
{
PathCharString pathstr;
CHAR * lpstr = nullptr;
INT name_length;
HMODULE hModule = nullptr;
PERF_ENTRY(RegisterLibraryDirect);
ENTRY("RegisterLibraryDirect (lpLibFileName=%p (%S)) \n",
lpLibFileName ? lpLibFileName : W16_NULLSTRING,
lpLibFileName ? lpLibFileName : W16_NULLSTRING);
if (!LOADVerifyLibraryPath(lpLibFileName))
{
goto done;
}
lpstr = pathstr.OpenStringBuffer((PAL_wcslen(lpLibFileName)+1) * MaxWCharToAcpLength);
if (nullptr == lpstr)
{
goto done;
}
if (!LOADConvertLibraryPathWideStringToMultibyteString(lpLibFileName, lpstr, &name_length))
{
goto done;
}
/* do the Dos/Unix conversion on our own copy of the name */
FILEDosToUnixPathA(lpstr);
pathstr.CloseBuffer(name_length);
/* let LOADRegisterLibraryDirect call SetLastError in case of failure */
LockModuleList();
hModule = LOADRegisterLibraryDirect((void *)dl_handle, lpstr, true /* fDynamic */);
UnlockModuleList();
done:
LOGEXIT("RegisterLibraryDirect returns HMODULE %p\n", hModule);
PERF_EXIT(RegisterLibraryDirect);
return hModule;
}
示例8: sizeof
bool SharedMemoryHelpers::AppendUInt32String(
PathCharString& destination,
UINT32 value)
{
char int32String[16];
int valueCharCount =
sprintf_s(int32String, sizeof(int32String), "%u", value);
_ASSERTE(valueCharCount > 0);
return destination.Append(int32String, valueCharCount) != FALSE;
}
示例9: PAL_LoadLibraryDirect
PALAPI
PAL_LoadLibraryDirect(
IN LPCWSTR lpLibFileName)
{
PathCharString pathstr;
CHAR * lpstr = nullptr;
INT name_length;
void *dl_handle = nullptr;
PERF_ENTRY(LoadLibraryDirect);
ENTRY("LoadLibraryDirect (lpLibFileName=%p (%S)) \n",
lpLibFileName ? lpLibFileName : W16_NULLSTRING,
lpLibFileName ? lpLibFileName : W16_NULLSTRING);
if (!LOADVerifyLibraryPath(lpLibFileName))
{
goto done;
}
lpstr = pathstr.OpenStringBuffer((PAL_wcslen(lpLibFileName)+1) * MaxWCharToAcpLength);
if (nullptr == lpstr)
{
goto done;
}
if (!LOADConvertLibraryPathWideStringToMultibyteString(lpLibFileName, lpstr, &name_length))
{
goto done;
}
/* do the Dos/Unix conversion on our own copy of the name */
FILEDosToUnixPathA(lpstr);
pathstr.CloseBuffer(name_length);
dl_handle = LOADLoadLibraryDirect(lpstr);
done:
LOGEXIT("LoadLibraryDirect returns HMODULE %p\n", dl_handle);
PERF_EXIT(LoadLibraryDirect);
return dl_handle;
}
示例10: PAL_GetPALDirectoryA
PALIMPORT
BOOL
PALAPI
PAL_GetPALDirectoryA(
OUT LPSTR lpDirectoryName,
IN UINT* cchDirectoryName)
{
BOOL bRet;
PathCharString directory;
PERF_ENTRY(PAL_GetPALDirectoryA);
ENTRY( "PAL_GetPALDirectoryA( %p, %d )\n", lpDirectoryName, *cchDirectoryName );
bRet = PAL_GetPALDirectoryA(directory);
if (bRet)
{
if (directory.GetCount() > *cchDirectoryName)
{
SetLastError( ERROR_INSUFFICIENT_BUFFER );
bRet = FALSE;
*cchDirectoryName = directory.GetCount();
}
else if (strcpy_s(lpDirectoryName, directory.GetCount(), directory.GetString()) == SAFECRT_SUCCESS)
{
}
else
{
bRet = FALSE;
}
}
LOGEXIT( "PAL_GetPALDirectoryA returns BOOL %d.\n", bRet);
PERF_EXIT(PAL_GetPALDirectoryA);
return bRet;
}
示例11: _ASSERTE
SharedMemoryProcessDataHeader *SharedMemoryProcessDataHeader::CreateOrOpen(
LPCSTR name,
SharedMemorySharedDataHeader requiredSharedDataHeader,
SIZE_T sharedDataByteCount,
bool createIfNotExist,
bool *createdRef)
{
_ASSERTE(name != nullptr);
_ASSERTE(sharedDataByteCount != 0);
_ASSERTE(!createIfNotExist || createdRef != nullptr);
_ASSERTE(SharedMemoryManager::IsCreationDeletionProcessLockAcquired());
_ASSERTE(!SharedMemoryManager::IsCreationDeletionFileLockAcquired());
if (createdRef != nullptr)
{
*createdRef = false;
}
PathCharString filePath;
SharedMemoryId id(name);
struct AutoCleanup
{
bool m_acquiredCreationDeletionFileLock;
PathCharString *m_filePath;
SIZE_T m_sessionDirectoryPathCharCount;
bool m_createdFile;
int m_fileDescriptor;
bool m_acquiredFileLock;
void *m_mappedBuffer;
SIZE_T m_mappedBufferByteCount;
bool m_cancel;
AutoCleanup()
: m_acquiredCreationDeletionFileLock(false),
m_filePath(nullptr),
m_sessionDirectoryPathCharCount(0),
m_createdFile(false),
m_fileDescriptor(-1),
m_acquiredFileLock(false),
m_mappedBuffer(nullptr),
m_mappedBufferByteCount(0),
m_cancel(false)
{
}
~AutoCleanup()
{
if (m_cancel)
{
return;
}
if (m_mappedBuffer != nullptr)
{
_ASSERTE(m_mappedBufferByteCount != 0);
munmap(m_mappedBuffer, m_mappedBufferByteCount);
}
if (m_acquiredFileLock)
{
_ASSERTE(m_fileDescriptor != -1);
SharedMemoryHelpers::ReleaseFileLock(m_fileDescriptor);
}
if (m_fileDescriptor != -1)
{
SharedMemoryHelpers::CloseFile(m_fileDescriptor);
}
if (m_createdFile)
{
_ASSERTE(m_filePath != nullptr);
unlink(*m_filePath);
}
if (m_sessionDirectoryPathCharCount != 0)
{
_ASSERTE(*m_filePath != nullptr);
m_filePath->CloseBuffer(m_sessionDirectoryPathCharCount);
rmdir(*m_filePath);
}
if (m_acquiredCreationDeletionFileLock)
{
SharedMemoryManager::ReleaseCreationDeletionFileLock();
}
}
} autoCleanup;
SharedMemoryProcessDataHeader *processDataHeader = SharedMemoryManager::FindProcessDataHeader(&id);
if (processDataHeader != nullptr)
{
_ASSERTE(
processDataHeader->GetSharedDataTotalByteCount() ==
SharedMemorySharedDataHeader::DetermineTotalByteCount(sharedDataByteCount));
processDataHeader->IncRefCount();
return processDataHeader;
}
//.........这里部分代码省略.........
示例12: CreateDirectoryA
/*++
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);
//.........这里部分代码省略.........
示例13: CopySharedMemoryBasePath
bool SharedMemoryManager::CopySharedMemoryBasePath(PathCharString& destination)
{
return destination.Set(*s_sharedMemoryDirectoryPath) != FALSE;
}
示例14: SetCurrentDirectoryW
/*++
Function:
SetCurrentDirectoryW
See MSDN doc.
--*/
BOOL
PALAPI
SetCurrentDirectoryW(
IN LPCWSTR lpPathName)
{
BOOL bRet;
DWORD dwLastError = 0;
PathCharString dirPathString;
int size;
size_t length;
char * dir;
PERF_ENTRY(SetCurrentDirectoryW);
ENTRY("SetCurrentDirectoryW(lpPathName=%p (%S))\n",
lpPathName?lpPathName:W16_NULLSTRING,
lpPathName?lpPathName:W16_NULLSTRING);
/*check if the given path is null. If so
return FALSE*/
if (lpPathName == NULL )
{
ERROR("Invalid path/directory name\n");
dwLastError = ERROR_INVALID_NAME;
bRet = FALSE;
goto done;
}
length = (PAL_wcslen(lpPathName)+1) * 3;
dir = dirPathString.OpenStringBuffer(length);
if (NULL == dir)
{
dwLastError = ERROR_NOT_ENOUGH_MEMORY;
bRet = FALSE;
goto done;
}
size = WideCharToMultiByte( CP_ACP, 0, lpPathName, -1, dir, length,
NULL, NULL );
dirPathString.CloseBuffer(size);
if( size == 0 )
{
dwLastError = GetLastError();
if( dwLastError == ERROR_INSUFFICIENT_BUFFER )
{
WARN("lpPathName is larger than MAX_LONGPATH (%d)!\n", MAX_LONGPATH);
dwLastError = ERROR_FILENAME_EXCED_RANGE;
}
else
{
ASSERT("WideCharToMultiByte failure! error is %d\n", dwLastError);
dwLastError = ERROR_INTERNAL_ERROR;
}
bRet = FALSE;
goto done;
}
bRet = SetCurrentDirectoryA(dir);
done:
if( dwLastError )
{
SetLastError(dwLastError);
}
LOGEXIT("SetCurrentDirectoryW returns BOOL %d\n", bRet);
PERF_EXIT(SetCurrentDirectoryW);
return bRet;
}
示例15: munmap
~AutoCleanup()
{
if (m_cancel)
{
return;
}
if (m_mappedBuffer != nullptr)
{
_ASSERTE(m_mappedBufferByteCount != 0);
munmap(m_mappedBuffer, m_mappedBufferByteCount);
}
if (m_acquiredFileLock)
{
_ASSERTE(m_fileDescriptor != -1);
SharedMemoryHelpers::ReleaseFileLock(m_fileDescriptor);
}
if (m_fileDescriptor != -1)
{
SharedMemoryHelpers::CloseFile(m_fileDescriptor);
}
if (m_createdFile)
{
_ASSERTE(m_filePath != nullptr);
unlink(*m_filePath);
}
if (m_sessionDirectoryPathCharCount != 0)
{
_ASSERTE(*m_filePath != nullptr);
m_filePath->CloseBuffer(m_sessionDirectoryPathCharCount);
rmdir(*m_filePath);
}
if (m_acquiredCreationDeletionFileLock)
{
SharedMemoryManager::ReleaseCreationDeletionFileLock();
}
}