//--- IOS_ERROR_CODE IOSFileExtractW( const WCHAR * pszFullFileName, WCHAR * pszFileName, uint uicchBufferLen ) { #if defined(_UNICODE) return ::IOSFileExtract( pszFullFileName, pszFileName, uicchBufferLen ); #else if ( pszFullFileName && pszFileName ) { if ( g_bUnicodePlatform ) { CAPointer<WCHAR> fFile = new WCHAR[_MAX_FNAME]; CAPointer<WCHAR> fExt = new WCHAR[_MAX_EXT]; // выделить диск и каталог _wsplitpath( pszFullFileName, NULL, NULL, fFile, fExt); if ( uint(wcslen(fFile) + wcslen(fExt)) < uicchBufferLen ) { wcscpy( pszFileName, fFile ); pszFileName = _wcsninc(pszFileName, wcslen(pszFileName) ); wcscpy( pszFileName, fExt ); } else return IOS_ERR_OUT_OF_MEMORY; return IOS_ERR_OK; } else { CPathStrA pConverted(pszFullFileName); CPathStrA pBuffer( (int)uicchBufferLen * 2 ); IOS_ERROR_CODE nError = ::IOSFileExtract( pConverted, pBuffer, uicchBufferLen * 2 ); wcsncpy( pszFileName, CPathStrW(pBuffer), uicchBufferLen ); return nError; } } return IOS_ERR_INVALID_FILE_NAME; #endif }
// --- BOOL CAvpFileFindW::IsDots() const { // return TRUE if the file name is "." or ".." and // the file is a directory BOOL bResult = FALSE; LPWIN32_FIND_DATAW pContext = GetContext(); if (pContext != NULL && IsDirectory()) { WCHAR *pFileName = pContext->cFileName; int n0 = _wcsnextc( _wcsninc(pFileName, 0) ); int n1 = _wcsnextc( _wcsninc(pFileName, 1) ); int n2 = _wcsnextc( _wcsninc(pFileName, 2) ); if ( n0 == L'.' ) { if ( n1 == L'\0' || ( n1 == L'.' && n2 == L'\0') ) { bResult = TRUE; } } } return bResult; }
// // Called the first time we use ClrRegCreateKeyEx or ClrRegOpenKeyEx to determine if the registry redirection // config value has been set. If so, we parse it into g_registryRoot // If the config string is mal-formed, we don't set the global variable. // HRESULT ParseRegistryRootConfigValue() { if (!IsNgenOffline()) { return ERROR_SUCCESS; } CLRConfigStringHolder configValue(CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_RegistryRoot)); // Since IsNgenOffline returned true, this better not be NULL if (configValue == NULL) return ERROR_BAD_ARGUMENTS; if (_wcsnicmp(configValue, wszHKLM, wcslen(wszHKLM)) != 0) { return ERROR_BAD_ARGUMENTS; } // The rest of the string is the location of the redirected registry key LPWSTR configValueKey = (LPWSTR)configValue; configValueKey = _wcsninc(configValueKey, wcslen(wszHKLM)); size_t len = wcslen(configValueKey) + 1; bool appendBackslash = false; if (configValueKey[wcslen(configValueKey) - 1] != W('\\')) { appendBackslash = true; len += wcslen(BACKSLASH_CHARACTER); } g_registryRoot = new (nothrow) WCHAR[len]; if (g_registryRoot == NULL) { return ERROR_NOT_ENOUGH_MEMORY; } wcscpy_s(g_registryRoot, len, configValueKey); if (appendBackslash) { StringCchCat(g_registryRoot, len, BACKSLASH_CHARACTER); } return ERROR_SUCCESS; }