本文整理汇总了C++中RTStrToUtf16函数的典型用法代码示例。如果您正苦于以下问题:C++ RTStrToUtf16函数的具体用法?C++ RTStrToUtf16怎么用?C++ RTStrToUtf16使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RTStrToUtf16函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: VBGLR3DECL
/**
* Retrieves and clears the user credentials for logging into the guest OS.
* UTF-16 version.
*
* @returns IPRT status value
* @param ppwszUser Receives pointer of allocated user name string.
* The returned pointer must be freed using VbglR3CredentialsDestroyUtf16().
* @param ppswzPassword Receives pointer of allocated user password string.
* The returned pointer must be freed using VbglR3CredentialsDestroyUtf16().
* @param ppwszDomain Receives pointer of allocated domain name string.
* The returned pointer must be freed using VbglR3CredentialsDestroyUtf16().
*/
VBGLR3DECL(int) VbglR3CredentialsRetrieveUtf16(PRTUTF16 *ppwszUser, PRTUTF16 *ppwszPassword, PRTUTF16 *ppwszDomain)
{
AssertPtrReturn(ppwszUser, VERR_INVALID_POINTER);
AssertPtrReturn(ppwszPassword, VERR_INVALID_POINTER);
AssertPtrReturn(ppwszDomain, VERR_INVALID_POINTER);
char *pszUser, *pszPassword, *pszDomain;
int rc = VbglR3CredentialsRetrieve(&pszUser, &pszPassword, &pszDomain);
if (RT_SUCCESS(rc))
{
PRTUTF16 pwszUser = NULL;
PRTUTF16 pwszPassword = NULL;
PRTUTF16 pwszDomain = NULL;
rc = RTStrToUtf16(pszUser, &pwszUser);
if (RT_SUCCESS(rc))
{
rc = RTStrToUtf16(pszPassword, &pwszPassword);
if (RT_SUCCESS(rc))
rc = RTStrToUtf16(pszDomain, &pwszDomain);
}
if (RT_SUCCESS(rc))
{
*ppwszUser = pwszUser;
*ppwszPassword = pwszPassword;
*ppwszDomain = pwszDomain;
}
else
VbglR3CredentialsDestroyUtf16(pwszUser, pwszPassword, pwszDomain, 3 /* Passes */);
VbglR3CredentialsDestroy(pszUser, pszPassword, pszDomain, 3 /* Passes */);
}
return rc;
}
开发者ID:bayasist,项目名称:vbox,代码行数:47,代码来源:VBoxGuestR3LibCredentials.cpp
示例2: rtFsGetRoot
/**
* Finds the root of the specified volume.
*
* @returns iprt status code.
* @param pszFsPath Path within the filesystem. Verified as one byte or more.
* @param ppwszFsRoot Where to store the returned string. Free with rtFsFreeRoot(),
*/
static int rtFsGetRoot(const char *pszFsPath, PRTUTF16 *ppwszFsRoot)
{
/*
* Do straight forward stuff first,
*/
if (rtFsIsRoot(pszFsPath))
return RTStrToUtf16(pszFsPath, ppwszFsRoot);
/*
* Expand and add slash (if required).
*/
char szFullPath[RTPATH_MAX];
int rc = RTPathAbs(pszFsPath, szFullPath, sizeof(szFullPath));
if (RT_FAILURE(rc))
return rc;
size_t cb = strlen(szFullPath);
if (!RTPATH_IS_SLASH(szFullPath[cb - 1]))
{
AssertReturn(cb + 1 < RTPATH_MAX, VERR_FILENAME_TOO_LONG);
szFullPath[cb] = '\\';
szFullPath[++cb] = '\0';
}
/*
* Convert the path.
*/
rc = RTStrToUtf16(szFullPath, ppwszFsRoot);
if (RT_FAILURE(rc))
return rc == VERR_BUFFER_OVERFLOW ? VERR_FILENAME_TOO_LONG : rc;
/*
* Walk the path until our proper API is happy or there is no more path left.
*/
PRTUTF16 pwszStart = *ppwszFsRoot;
if (!GetVolumeInformationW(pwszStart, NULL, 0, NULL, NULL, 0, NULL, 0))
{
PRTUTF16 pwszEnd = pwszStart + RTUtf16Len(pwszStart);
PRTUTF16 pwszMin = pwszStart + 2;
do
{
/* Strip off the last path component. */
while (pwszEnd-- > pwszMin)
if (RTPATH_IS_SLASH(*pwszEnd))
break;
AssertReturn(pwszEnd >= pwszMin, VERR_INTERNAL_ERROR); /* leaks, but that's irrelevant for an internal error. */
pwszEnd[1] = '\0';
} while (!GetVolumeInformationW(pwszStart, NULL, 0, NULL, NULL, 0, NULL, 0));
}
return VINF_SUCCESS;
}
开发者ID:LastRitter,项目名称:vbox-haiku,代码行数:58,代码来源:fs-win.cpp
示例3: RTDECL
RTDECL(int) RTEnvGetUtf8(const char *pszVar, char *pszValue, size_t cbValue, size_t *pcchActual)
{
AssertPtrReturn(pszVar, VERR_INVALID_POINTER);
AssertPtrNullReturn(pszValue, VERR_INVALID_POINTER);
AssertReturn(pszValue || !cbValue, VERR_INVALID_PARAMETER);
AssertPtrNullReturn(pcchActual, VERR_INVALID_POINTER);
AssertReturn(pcchActual || (pszValue && cbValue), VERR_INVALID_PARAMETER);
AssertReturn(strchr(pszVar, '=') == NULL, VERR_ENV_INVALID_VAR_NAME);
if (pcchActual)
*pcchActual = 0;
PRTUTF16 pwszVar;
int rc = RTStrToUtf16(pszVar, &pwszVar);
AssertRCReturn(rc, rc);
/** @todo Consider _wgetenv_s or GetEnvironmentVariableW here to avoid the
* potential race with a concurrent _wputenv/_putenv. */
PCRTUTF16 pwszValue = _wgetenv(pwszVar);
RTUtf16Free(pwszVar);
if (pwszValue)
{
if (cbValue)
rc = RTUtf16ToUtf8Ex(pwszValue, RTSTR_MAX, &pszValue, cbValue, pcchActual);
else
rc = RTUtf16CalcUtf8LenEx(pwszValue, RTSTR_MAX, pcchActual);
}
else
rc = VERR_ENV_VAR_NOT_FOUND;
return rc;
}
开发者ID:svn2github,项目名称:virtualbox,代码行数:31,代码来源:env-win.cpp
示例4: RTDECL
RTDECL(int) RTPathSetCurrent(const char *pszPath)
{
/*
* Validate input.
*/
AssertPtrReturn(pszPath, VERR_INVALID_POINTER);
AssertReturn(*pszPath, VERR_INVALID_PARAMETER);
/*
* This interface is almost identical to the Windows API.
*/
PRTUTF16 pwszPath;
int rc = RTStrToUtf16(pszPath, &pwszPath);
if (RT_SUCCESS(rc))
{
/** @todo improve the slash stripping a bit? */
size_t cwc = RTUtf16Len(pwszPath);
if ( cwc >= 2
&& ( pwszPath[cwc - 1] == L'/'
|| pwszPath[cwc - 1] == L'\\')
&& pwszPath[cwc - 2] != ':')
pwszPath[cwc - 1] = L'\0';
if (!SetCurrentDirectoryW(pwszPath))
rc = RTErrConvertFromWin32(GetLastError());
RTUtf16Free(pwszPath);
}
return rc;
}
开发者ID:greg100795,项目名称:virtualbox,代码行数:30,代码来源:path-win.cpp
示例5: openCertStore
/**
* Opens a certificate store.
*
* @returns true on success, false on failure (error message written).
* @param dwDst The destination, like
* CERT_SYSTEM_STORE_LOCAL_MACHINE or
* CERT_SYSTEM_STORE_CURRENT_USER.
* @param pszStoreNm The store name.
*/
static HCERTSTORE openCertStore(DWORD dwDst, const char *pszStoreNm)
{
HCERTSTORE hStore = NULL;
PRTUTF16 pwszStoreNm;
int rc = RTStrToUtf16(pszStoreNm, &pwszStoreNm);
if (RT_SUCCESS(rc))
{
/*
* Make sure CERT_STORE_OPEN_EXISTING_FLAG is not set. This causes Windows XP
* to return ACCESS_DENIED when installing TrustedPublisher certificates via
* CertAddCertificateContextToStore() if the TrustedPublisher store never has
* been used (through certmgr.exe and friends) yet.
*
* According to MSDN, if neither CERT_STORE_OPEN_EXISTING_FLAG nor
* CERT_STORE_CREATE_NEW_FLAG is set, the store will be either opened or
* created accordingly.
*/
dwDst &= ~CERT_STORE_OPEN_EXISTING_FLAG;
hStore = CertOpenStore(CERT_STORE_PROV_SYSTEM_W,
PKCS_7_ASN_ENCODING | X509_ASN_ENCODING,
NULL /* hCryptProv = default */,
dwDst,
pwszStoreNm);
RTUtf16Free(pwszStoreNm);
}
return hStore;
}
开发者ID:etiago,项目名称:vbox,代码行数:38,代码来源:VBoxStubCertUtil.cpp
示例6: RTR3DECL
RTR3DECL(int) RTFsQueryType(const char *pszFsPath, PRTFSTYPE penmType)
{
*penmType = RTFSTYPE_UNKNOWN;
AssertPtrReturn(pszFsPath, VERR_INVALID_POINTER);
AssertReturn(*pszFsPath, VERR_INVALID_PARAMETER);
/*
* Convert the path and try open it.
*/
PRTUTF16 pwszFsPath;
int rc = RTStrToUtf16(pszFsPath, &pwszFsPath);
if (RT_SUCCESS(rc))
{
HANDLE hFile = CreateFileW(pwszFsPath,
GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
NULL,
OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS,
NULL);
if (hFile != INVALID_HANDLE_VALUE)
{
/*
* Use the NT api directly to get the file system name.
*/
char abBuf[8192];
IO_STATUS_BLOCK Ios;
NTSTATUS rcNt = NtQueryVolumeInformationFile(hFile, &Ios,
abBuf, sizeof(abBuf),
FileFsAttributeInformation);
if (rcNt >= 0)
{
PFILE_FS_ATTRIBUTE_INFORMATION pFsAttrInfo = (PFILE_FS_ATTRIBUTE_INFORMATION)abBuf;
if (pFsAttrInfo->FIleSystemNameLength)
{
}
#define IS_FS(szName) \
rtFsWinAreEqual(pFsAttrInfo->FileSystemName, pFsAttrInfo->FIleSystemNameLength, szName, sizeof(szName) - 1)
if (IS_FS("NTFS"))
*penmType = RTFSTYPE_NTFS;
else if (IS_FS("FAT"))
*penmType = RTFSTYPE_FAT;
else if (IS_FS("FAT32"))
*penmType = RTFSTYPE_FAT;
else if (IS_FS("VBoxSharedFolderFS"))
*penmType = RTFSTYPE_VBOXSHF;
#undef IS_FS
}
else
rc = RTErrConvertFromNtStatus(rcNt);
CloseHandle(hFile);
}
else
rc = RTErrConvertFromWin32(GetLastError());
RTUtf16Free(pwszFsPath);
}
return rc;
}
开发者ID:LastRitter,项目名称:vbox-haiku,代码行数:59,代码来源:fs-win.cpp
示例7: DECLHIDDEN
/**
* Internal worker for RTFileRename and RTFileMove.
*
* @returns iprt status code.
* @param pszSrc The source filename.
* @param pszDst The destination filename.
* @param fFlags The windows MoveFileEx flags.
* @param fFileType The filetype. We use the RTFMODE filetypes here. If it's 0,
* anything goes. If it's RTFS_TYPE_DIRECTORY we'll check that the
* source is a directory. If Its RTFS_TYPE_FILE we'll check that it's
* not a directory (we are NOT checking whether it's a file).
*/
DECLHIDDEN(int) rtPathWin32MoveRename(const char *pszSrc, const char *pszDst, uint32_t fFlags, RTFMODE fFileType)
{
/*
* Convert the strings.
*/
PRTUTF16 pwszSrc;
int rc = RTStrToUtf16(pszSrc, &pwszSrc);
if (RT_SUCCESS(rc))
{
PRTUTF16 pwszDst;
rc = RTStrToUtf16(pszDst, &pwszDst);
if (RT_SUCCESS(rc))
{
/*
* Check object type if requested.
* This is open to race conditions.
*/
if (fFileType)
{
DWORD dwAttr = GetFileAttributesW(pwszSrc);
if (dwAttr == INVALID_FILE_ATTRIBUTES)
rc = RTErrConvertFromWin32(GetLastError());
else if (RTFS_IS_DIRECTORY(fFileType))
rc = dwAttr & FILE_ATTRIBUTE_DIRECTORY ? VINF_SUCCESS : VERR_NOT_A_DIRECTORY;
else
rc = dwAttr & FILE_ATTRIBUTE_DIRECTORY ? VERR_IS_A_DIRECTORY : VINF_SUCCESS;
}
if (RT_SUCCESS(rc))
{
if (MoveFileExW(pwszSrc, pwszDst, fFlags))
rc = VINF_SUCCESS;
else
{
DWORD Err = GetLastError();
rc = RTErrConvertFromWin32(Err);
Log(("MoveFileExW('%s', '%s', %#x, %RTfmode): fails with rc=%Rrc & lasterr=%d\n",
pszSrc, pszDst, fFlags, fFileType, rc, Err));
}
}
RTUtf16Free(pwszDst);
}
RTUtf16Free(pwszSrc);
}
return rc;
}
开发者ID:greg100795,项目名称:virtualbox,代码行数:57,代码来源:path-win.cpp
示例8: rtLocalIpcServerWinAllocSecurityDescriptior
/**
* Builds and allocates the security descriptor required for securing the local pipe.
*
* @return IPRT status code.
* @param ppDesc Where to store the allocated security descriptor on success.
* Must be free'd using LocalFree().
*/
static int rtLocalIpcServerWinAllocSecurityDescriptior(PSECURITY_DESCRIPTOR *ppDesc, bool fServer)
{
/** @todo Stuff this into RTInitOnce? Later. */
PFNCONVERTSTRINGSECURITYDESCRIPTORTOSECURITYDESCRIPTOR
pfnConvertStringSecurityDescriptorToSecurityDescriptor = NULL;
RTLDRMOD hAdvApi32 = NIL_RTLDRMOD;
int rc = RTLdrLoadSystem("Advapi32.dll", true /*fNoUnload*/, &hAdvApi32);
if (RT_SUCCESS(rc))
rc = RTLdrGetSymbol(hAdvApi32, "ConvertStringSecurityDescriptorToSecurityDescriptorW",
(void**)&pfnConvertStringSecurityDescriptorToSecurityDescriptor);
PSECURITY_DESCRIPTOR pSecDesc = NULL;
if (RT_SUCCESS(rc))
{
AssertPtr(pfnConvertStringSecurityDescriptorToSecurityDescriptor);
/*
* We'll create a security descriptor from a SDDL that denies
* access to network clients (this is local IPC after all), it
* makes some further restrictions to prevent non-authenticated
* users from screwing around.
*/
PRTUTF16 pwszSDDL;
rc = RTStrToUtf16(fServer
? RTLOCALIPC_WIN_SDDL_SERVER : RTLOCALIPC_WIN_SDDL_CLIENT, &pwszSDDL);
if (RT_SUCCESS(rc))
{
if (!pfnConvertStringSecurityDescriptorToSecurityDescriptor((LPCTSTR)pwszSDDL,
SDDL_REVISION_1,
&pSecDesc,
NULL))
{
rc = RTErrConvertFromWin32(GetLastError());
}
RTUtf16Free(pwszSDDL);
}
}
else
{
/* Windows OSes < W2K SP2 not supported for now, bail out. */
/** @todo Implement me! */
rc = VERR_NOT_SUPPORTED;
}
if (hAdvApi32 != NIL_RTLDRMOD)
RTLdrClose(hAdvApi32);
if (RT_SUCCESS(rc))
{
AssertPtr(pSecDesc);
*ppDesc = pSecDesc;
}
return rc;
}
开发者ID:apaka,项目名称:vbox,代码行数:64,代码来源:localipc-win.cpp
示例9: RTDECL
RTDECL(int) RTDirCreate(const char *pszPath, RTFMODE fMode, uint32_t fCreate)
{
/*
* Validate the file mode.
*/
int rc;
fMode = rtFsModeNormalize(fMode, pszPath, 0);
if (rtFsModeIsValidPermissions(fMode))
{
/*
* Convert to UTF-16.
*/
PRTUTF16 pwszString;
rc = RTStrToUtf16(pszPath, &pwszString);
AssertRC(rc);
if (RT_SUCCESS(rc))
{
/*
* Create the directory.
*/
if (CreateDirectoryW((LPCWSTR)pwszString, NULL))
rc = VINF_SUCCESS;
else
rc = RTErrConvertFromWin32(GetLastError());
/*
* Turn off indexing of directory through Windows Indexing Service
*/
/** @todo This FILE_ATTRIBUTE_NOT_CONTENT_INDEXED hack (for .VDI files,
* really) may cause failures on samba shares. That really sweet and
* need to be addressed differently. We shouldn't be doing this
* unless the caller actually asks for it, must less returning failure,
* for crying out loud! This is only important a couple of places in
* main, if important is the right way to put it... */
if ( RT_SUCCESS(rc)
&& !(fCreate & RTDIRCREATE_FLAGS_NOT_CONTENT_INDEXED_DONT_SET))
{
if ( SetFileAttributesW((LPCWSTR)pwszString, FILE_ATTRIBUTE_NOT_CONTENT_INDEXED)
|| (fCreate & RTDIRCREATE_FLAGS_NOT_CONTENT_INDEXED_NOT_CRITICAL) )
rc = VINF_SUCCESS;
else
rc = RTErrConvertFromWin32(GetLastError());
}
RTUtf16Free(pwszString);
}
}
else
{
AssertMsgFailed(("Invalid file mode! %RTfmode\n", fMode));
rc = VERR_INVALID_FMODE;
}
LogFlow(("RTDirCreate(%p:{%s}, %RTfmode): returns %Rrc\n", pszPath, pszPath, fMode, rc));
return rc;
}
开发者ID:sobomax,项目名称:virtualbox_64bit_edd,代码行数:56,代码来源:dir-win.cpp
示例10: rtSystemWinBstrFromUtf8
/**
* Convert a UTF-8 string to a BSTR.
*
* @returns BSTR pointer.
* @param psz The UTF-8 string.
*/
static BSTR rtSystemWinBstrFromUtf8(const char *psz)
{
PRTUTF16 pwsz = NULL;
int rc = RTStrToUtf16(psz, &pwsz);
if (RT_FAILURE(rc))
return NULL;
BSTR pBStr = SysAllocString((const OLECHAR *)pwsz);
RTUtf16Free(pwsz);
return pBStr;
}
开发者ID:LastRitter,项目名称:vbox-haiku,代码行数:16,代码来源:RTSystemQueryDmiString-win.cpp
示例11: RTDECL
RTDECL(int) RTGetOptArgvToUtf16String(PRTUTF16 *ppwszCmdLine, const char * const *papszArgv, uint32_t fFlags)
{
char *pszCmdLine;
int rc = RTGetOptArgvToString(&pszCmdLine, papszArgv, fFlags);
if (RT_SUCCESS(rc))
{
rc = RTStrToUtf16(pszCmdLine, ppwszCmdLine);
RTStrFree(pszCmdLine);
}
return rc;
}
开发者ID:marktsai0316,项目名称:VirtualMonitor,代码行数:11,代码来源:getoptargv.cpp
示例12: rtDirNativeOpen
int rtDirNativeOpen(PRTDIR pDir, char *pszPathBuf)
{
/*
* Setup the search expression.
*
* pszPathBuf is pointing to the return 4K return buffer for the RTPathReal()
* call in rtDirOpenCommon(), so all we gota do is check that we don't overflow
* it when adding the wildcard expression.
*/
size_t cbExpr;
const char *pszExpr;
if (pDir->enmFilter == RTDIRFILTER_WINNT)
{
pszExpr = pDir->pszFilter;
cbExpr = pDir->cchFilter + 1;
}
else
{
pszExpr = "*";
cbExpr = sizeof("*");
}
if (pDir->cchPath + cbExpr > RTPATH_MAX)
return VERR_FILENAME_TOO_LONG;
memcpy(pszPathBuf + pDir->cchPath, pszExpr, cbExpr);
/*
* Attempt opening the search.
*/
int rc = VINF_SUCCESS;
PRTUTF16 pwszName;
rc = RTStrToUtf16(pszPathBuf, &pwszName);
if (RT_SUCCESS(rc))
{
pDir->hDir = FindFirstFileW((LPCWSTR)pwszName, &pDir->Data);
if (pDir->hDir != INVALID_HANDLE_VALUE)
pDir->fDataUnread = true;
else
{
DWORD dwErr = GetLastError();
/* Theoretical case of an empty directory or more normal case of no matches. */
if ( dwErr == ERROR_FILE_NOT_FOUND
|| dwErr == ERROR_NO_MORE_FILES /* ???*/)
pDir->fDataUnread = false;
else
rc = RTErrConvertFromWin32(GetLastError());
}
RTUtf16Free(pwszName);
}
return rc;
}
开发者ID:miguelinux,项目名称:vbox,代码行数:52,代码来源:direnum-win.cpp
示例13: RTR3DECL
RTR3DECL(int) RTFileDelete(const char *pszFilename)
{
PRTUTF16 pwszFilename;
int rc = RTStrToUtf16(pszFilename, &pwszFilename);
if (RT_SUCCESS(rc))
{
if (!DeleteFileW(pwszFilename))
rc = RTErrConvertFromWin32(GetLastError());
RTUtf16Free(pwszFilename);
}
return rc;
}
开发者ID:sobomax,项目名称:virtualbox_64bit_edd,代码行数:13,代码来源:fileio-win.cpp
示例14: rtDirNativeOpen
int rtDirNativeOpen(PRTDIR pDir, char *pszPathBuf)
{
/*
* Convert the filter to UTF-16.
*/
int rc;
pDir->pNtFilterStr = NULL;
if ( pDir->cchFilter > 0
&& pDir->enmFilter == RTDIRFILTER_WINNT)
{
PRTUTF16 pwszTmp;
rc = RTStrToUtf16(pDir->pszFilter, &pwszTmp);
if (RT_FAILURE(rc))
return rc;
pDir->NtFilterStr.Buffer = pwszTmp;
pDir->NtFilterStr.Length = pDir->NtFilterStr.MaximumLength = (uint16_t)(RTUtf16Len(pwszTmp) * sizeof(RTUTF16));
pDir->pNtFilterStr = &pDir->NtFilterStr;
}
/*
* Try open the directory
*/
#ifdef IPRT_WITH_NT_PATH_PASSTHRU
bool fObjDir;
#endif
rc = rtNtPathOpenDir(pszPathBuf,
FILE_READ_DATA | SYNCHRONIZE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
FILE_DIRECTORY_FILE | FILE_OPEN_FOR_BACKUP_INTENT | FILE_SYNCHRONOUS_IO_NONALERT,
OBJ_CASE_INSENSITIVE,
&pDir->hDir,
#ifdef IPRT_WITH_NT_PATH_PASSTHRU
&fObjDir
#else
NULL
#endif
);
if (RT_SUCCESS(rc))
{
/*
* Init data.
*/
pDir->fDataUnread = false; /* spelling it out */
#ifdef IPRT_WITH_NT_PATH_PASSTHRU
if (fObjDir)
pDir->enmInfoClass = FileMaximumInformation; /* object directory. */
#endif
}
return rc;
}
开发者ID:MadHacker217,项目名称:VirtualBox-OSE,代码行数:50,代码来源:direnum-r3-nt.cpp
示例15: vbsfMapFolder
int vbsfMapFolder(PSHFLCLIENTDATA pClient, PSHFLSTRING pszMapName,
RTUTF16 pwszDelimiter, bool fCaseSensitive, SHFLROOT *pRoot)
{
MAPPING *pFolderMapping = NULL;
if (BIT_FLAG(pClient->fu32Flags, SHFL_CF_UTF8))
{
Log(("vbsfMapFolder %s\n", pszMapName->String.utf8));
}
else
{
Log(("vbsfMapFolder %ls\n", pszMapName->String.ucs2));
}
if (pClient->PathDelimiter == 0)
{
pClient->PathDelimiter = pwszDelimiter;
}
else
{
Assert(pwszDelimiter == pClient->PathDelimiter);
}
if (BIT_FLAG(pClient->fu32Flags, SHFL_CF_UTF8))
{
int rc;
PRTUTF16 utf16Name;
rc = RTStrToUtf16 ((const char *) pszMapName->String.utf8, &utf16Name);
if (RT_FAILURE (rc))
return rc;
pFolderMapping = vbsfMappingGetByName(utf16Name, pRoot);
RTUtf16Free (utf16Name);
}
else
{
pFolderMapping = vbsfMappingGetByName(pszMapName->String.ucs2, pRoot);
}
if (!pFolderMapping)
{
return VERR_FILE_NOT_FOUND;
}
pFolderMapping->cMappings++;
Assert(pFolderMapping->cMappings == 1 || pFolderMapping->fGuestCaseSensitive == fCaseSensitive);
pFolderMapping->fGuestCaseSensitive = fCaseSensitive;
return VINF_SUCCESS;
}
开发者ID:MadHacker217,项目名称:VirtualBox-OSE,代码行数:50,代码来源:mappings.cpp
示例16: RTDECL
/**
* Get the absolute path (no symlinks, no . or .. components), doesn't have to exit.
*
* @returns iprt status code.
* @param pszPath The path to resolve.
* @param pszAbsPath Where to store the absolute path.
* @param cchAbsPath Size of the buffer.
*/
RTDECL(int) RTPathAbs(const char *pszPath, char *pszAbsPath, size_t cchAbsPath)
{
/*
* Validation.
*/
AssertPtr(pszAbsPath);
AssertPtr(pszPath);
if (RT_UNLIKELY(!*pszPath))
return VERR_INVALID_PARAMETER;
/*
* Convert to UTF-16, call Win32 API, convert back.
*/
LPWSTR pwszPath;
int rc = RTStrToUtf16(pszPath, &pwszPath);
if (!RT_SUCCESS(rc))
return (rc);
LPWSTR pwszFile; /* Ignored */
RTUTF16 wsz[RTPATH_MAX];
rc = GetFullPathNameW(pwszPath, RT_ELEMENTS(wsz), &wsz[0], &pwszFile);
if (rc > 0 && rc < RT_ELEMENTS(wsz))
{
size_t cch;
rc = RTUtf16ToUtf8Ex(&wsz[0], RTSTR_MAX, &pszAbsPath, cchAbsPath, &cch);
if (RT_SUCCESS(rc))
{
# if 1 /** @todo This code is completely bonkers. */
/*
* Remove trailing slash if the path may be pointing to a directory.
* (See posix variant.)
*/
if ( cch > 1
&& RTPATH_IS_SLASH(pszAbsPath[cch - 1])
&& !RTPATH_IS_VOLSEP(pszAbsPath[cch - 2])
&& !RTPATH_IS_SLASH(pszAbsPath[cch - 2]))
pszAbsPath[cch - 1] = '\0';
# endif
}
}
else if (rc <= 0)
rc = RTErrConvertFromWin32(GetLastError());
else
rc = VERR_FILENAME_TOO_LONG;
RTUtf16Free(pwszPath);
return rc;
}
开发者ID:stefano-garzarella,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:56,代码来源:path-win.cpp
示例17: RTDECL
RTDECL(int) RTDirCreate(const char *pszPath, RTFMODE fMode)
{
/*
* Validate the file mode.
*/
int rc;
fMode = rtFsModeNormalize(fMode, pszPath, 0);
if (rtFsModeIsValidPermissions(fMode))
{
/*
* Convert to UTF-16.
*/
PRTUTF16 pwszString;
rc = RTStrToUtf16(pszPath, &pwszString);
AssertRC(rc);
if (RT_SUCCESS(rc))
{
/*
* Create the directory.
*/
if (CreateDirectoryW((LPCWSTR)pwszString, NULL))
rc = VINF_SUCCESS;
else
rc = RTErrConvertFromWin32(GetLastError());
/*
* Turn off indexing of directory through Windows Indexing Service
*/
if (RT_SUCCESS(rc))
{
if (SetFileAttributesW((LPCWSTR)pwszString, FILE_ATTRIBUTE_NOT_CONTENT_INDEXED))
rc = VINF_SUCCESS;
else
rc = RTErrConvertFromWin32(GetLastError());
}
RTUtf16Free(pwszString);
}
}
else
{
AssertMsgFailed(("Invalid file mode! %RTfmode\n", fMode));
rc = VERR_INVALID_FMODE;
}
LogFlow(("RTDirCreate(%p:{%s}, %RTfmode): returns %Rrc\n", pszPath, pszPath, fMode, rc));
return rc;
}
开发者ID:LastRitter,项目名称:vbox-haiku,代码行数:48,代码来源:dir-win.cpp
示例18: RTDECL
RTDECL(int) RTSymlinkDelete(const char *pszSymlink, uint32_t fDelete)
{
/*
* Convert the path.
*/
PRTUTF16 pwszNativeSymlink;
int rc = RTStrToUtf16(pszSymlink, &pwszNativeSymlink);
if (RT_SUCCESS(rc))
{
/*
* We have to use different APIs depending on whether this is a
* directory or file link. This means we're subject to one more race
* than on posix at the moment. We could probably avoid this though,
* if we wanted to go talk with the native API layer below Win32...
*/
DWORD dwAttr = GetFileAttributesW(pwszNativeSymlink);
if (dwAttr != INVALID_FILE_ATTRIBUTES)
{
if (dwAttr & FILE_ATTRIBUTE_REPARSE_POINT)
{
BOOL fRc;
if (dwAttr & FILE_ATTRIBUTE_DIRECTORY)
fRc = RemoveDirectoryW(pwszNativeSymlink);
else
fRc = DeleteFileW(pwszNativeSymlink);
if (fRc)
rc = VINF_SUCCESS;
else
rc = RTErrConvertFromWin32(GetLastError());
}
else
rc = VERR_NOT_SYMLINK;
}
else
rc = RTErrConvertFromWin32(GetLastError());
RTUtf16Free(pwszNativeSymlink);
}
LogFlow(("RTSymlinkDelete(%p={%s}, %#x): returns %Rrc\n", pszSymlink, pszSymlink, fDelete, rc));
return rc;
}
开发者ID:mutoso-mirrors,项目名称:vbox,代码行数:41,代码来源:symlink-win.cpp
示例19: openCertStore
/**
* Opens a certificate store.
*
* @returns true on success, false on failure (error message written).
* @param dwDst The destination, like
* CERT_SYSTEM_STORE_LOCAL_MACHINE or
* ERT_SYSTEM_STORE_CURRENT_USER.
* @param pszStoreNm The store name.
*/
static HCERTSTORE openCertStore(DWORD dwDst, const char *pszStoreNm)
{
HCERTSTORE hStore = NULL;
PRTUTF16 pwszStoreNm;
int rc = RTStrToUtf16(pszStoreNm, &pwszStoreNm);
if (RT_SUCCESS(rc))
{
if (g_cVerbosityLevel > 1)
RTMsgInfo("Opening store %#x:'%s'", dwDst, pszStoreNm);
hStore = CertOpenStore(CERT_STORE_PROV_SYSTEM_W,
PKCS_7_ASN_ENCODING | X509_ASN_ENCODING,
NULL /* hCryptProv = default */,
dwDst | CERT_STORE_OPEN_EXISTING_FLAG,
pwszStoreNm);
if (hStore == NULL)
RTMsgError("CertOpenStore failed opening %#x:'%s': %s",
dwDst, pszStoreNm, errorToString(GetLastError()));
RTUtf16Free(pwszStoreNm);
}
return hStore;
}
开发者ID:dezelin,项目名称:vbox,代码行数:32,代码来源:VBoxCertUtil.cpp
示例20: main
int main(int argc, char **argv)
{
RTTEST hTest;
int rc = RTTestInitAndCreate("tstRTUuid", &hTest);
if (rc)
return rc;
RTTestBanner(hTest);
#define CHECK_RC() \
do { if (RT_FAILURE(rc)) { RTTestFailed(hTest, "line %d: rc=%Rrc", __LINE__, rc); } } while (0)
RTTestSub(hTest, "RTUuidClear & RTUuisIsNull");
RTUUID UuidNull;
rc = RTUuidClear(&UuidNull); CHECK_RC();
RTTEST_CHECK(hTest, RTUuidIsNull(&UuidNull));
RTTEST_CHECK(hTest, RTUuidCompare(&UuidNull, &UuidNull) == 0);
RTTestSub(hTest, "RTUuidCreate");
RTUUID Uuid;
rc = RTUuidCreate(&Uuid); CHECK_RC();
RTTEST_CHECK(hTest, !RTUuidIsNull(&Uuid));
RTTEST_CHECK(hTest, RTUuidCompare(&Uuid, &Uuid) == 0);
RTTEST_CHECK(hTest, RTUuidCompare(&Uuid, &UuidNull) > 0);
RTTEST_CHECK(hTest, RTUuidCompare(&UuidNull, &Uuid) < 0);
RTTestSub(hTest, "RTUuidToStr");
char sz[RTUUID_STR_LENGTH];
rc = RTUuidToStr(&Uuid, sz, sizeof(sz)); CHECK_RC();
RTTEST_CHECK(hTest, strlen(sz) == RTUUID_STR_LENGTH - 1);
RTTestPrintf(hTest, RTTESTLVL_INFO, "UUID=%s\n", sz);
RTTestSub(hTest, "RTUuidFromStr");
RTUUID Uuid2;
rc = RTUuidFromStr(&Uuid2, sz); CHECK_RC();
RTTEST_CHECK(hTest, RTUuidCompare(&Uuid, &Uuid2) == 0);
char *psz = (char *)RTTestGuardedAllocTail(hTest, RTUUID_STR_LENGTH);
if (psz)
{
RTStrPrintf(psz, RTUUID_STR_LENGTH, "%s", sz);
RTTESTI_CHECK_RC(RTUuidFromStr(&Uuid2, psz), VINF_SUCCESS);
RTTEST_CHECK(hTest, RTUuidCompare(&Uuid, &Uuid2) == 0);
for (unsigned off = 1; off < RTUUID_STR_LENGTH; off++)
{
char *psz2 = psz + off;
RTStrPrintf(psz2, RTUUID_STR_LENGTH - off, "%s", sz);
RTTESTI_CHECK_RC(RTUuidFromStr(&Uuid2, psz2), VERR_INVALID_UUID_FORMAT);
}
RTTestGuardedFree(hTest, psz);
}
RTUuidClear(&Uuid2);
char sz2[RTUUID_STR_LENGTH + 2];
RTStrPrintf(sz2, sizeof(sz2), "{%s}", sz);
rc = RTUuidFromStr(&Uuid2, sz2); CHECK_RC();
RTTEST_CHECK(hTest, RTUuidCompare(&Uuid, &Uuid2) == 0);
psz = (char *)RTTestGuardedAllocTail(hTest, RTUUID_STR_LENGTH + 2);
if (psz)
{
RTStrPrintf(psz, RTUUID_STR_LENGTH + 2, "{%s}", sz);
RTTESTI_CHECK_RC(RTUuidFromStr(&Uuid2, psz), VINF_SUCCESS);
RTTEST_CHECK(hTest, RTUuidCompare(&Uuid, &Uuid2) == 0);
for (unsigned off = 1; off < RTUUID_STR_LENGTH + 2; off++)
{
char *psz2 = psz + off;
RTStrPrintf(psz2, RTUUID_STR_LENGTH + 2 - off, "{%s}", sz);
RTTESTI_CHECK_RC(RTUuidFromStr(&Uuid2, psz2), VERR_INVALID_UUID_FORMAT);
}
RTTestGuardedFree(hTest, psz);
}
RTTestSub(hTest, "RTUuidToUtf16");
RTUTF16 wsz[RTUUID_STR_LENGTH];
rc = RTUuidToUtf16(&Uuid, wsz, sizeof(wsz)); CHECK_RC();
RTTEST_CHECK(hTest, RTUtf16Len(wsz) == RTUUID_STR_LENGTH - 1);
RTTestSub(hTest, "RTUuidFromUtf16");
rc = RTUuidFromUtf16(&Uuid2, wsz); CHECK_RC();
RTTEST_CHECK(hTest, RTUuidCompare(&Uuid, &Uuid2) == 0);
RTUTF16 *pwsz;
rc = RTStrToUtf16(sz2, &pwsz);
RTTEST_CHECK(hTest, rc == VINF_SUCCESS);
if (RT_SUCCESS(rc))
{
RTTESTI_CHECK_RC(RTUuidFromUtf16(&Uuid2, pwsz), VINF_SUCCESS);
RTTEST_CHECK(hTest, RTUuidCompare(&Uuid, &Uuid2) == 0);
RTUTF16 *pwsz2 = (RTUTF16*)RTTestGuardedAllocTail(hTest, 2 * (RTUUID_STR_LENGTH + 2));
if (pwsz2)
{
memcpy(pwsz2, pwsz, 2 * (RTUUID_STR_LENGTH + 2));
RTTESTI_CHECK_RC(RTUuidFromUtf16(&Uuid2, pwsz2), VINF_SUCCESS);
RTTEST_CHECK(hTest, RTUuidCompare(&Uuid, &Uuid2) == 0);
for (unsigned off = 1; off < RTUUID_STR_LENGTH + 2; off++)
{
RTUTF16 *pwsz3 = pwsz2 + off;
memcpy(pwsz3, pwsz, 2 * (RTUUID_STR_LENGTH + 1 - off));
//.........这里部分代码省略.........
开发者ID:stefano-garzarella,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:101,代码来源:tstRTUuid.cpp
注:本文中的RTStrToUtf16函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论