本文整理汇总了C++中RTPathFilename函数的典型用法代码示例。如果您正苦于以下问题:C++ RTPathFilename函数的具体用法?C++ RTPathFilename怎么用?C++ RTPathFilename使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RTPathFilename函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rtDbgSymCacheAddFileOrDir
/**
* Adds a file or directory.
*
* @returns Program exit code.
* @param pszPath The user supplied path to the file or directory.
* @param pszCache The path to the cache.
* @param fRecursive Whether to process directories recursively.
* @param fOverwriteOnConflict Whether to overwrite existing cache entry on
* conflict, or just leave it.
*/
static RTEXITCODE rtDbgSymCacheAddFileOrDir(const char *pszPath, const char *pszCache, bool fRecursive,
bool fOverwriteOnConflict)
{
RT_NOREF1(fOverwriteOnConflict);
RTDBGSYMCACHEADDCFG Cfg;
Cfg.fRecursive = fRecursive;
Cfg.pszCache = pszCache;
Cfg.pszFilter = NULL;
int rc;
RTDBGSYMCACHEFILETYPE enmType = rtDbgSymCacheFigureType(pszPath);
switch (enmType)
{
default:
case RTDBGSYMCACHEFILETYPE_INVALID:
return RTMsgErrorExit(RTEXITCODE_FAILURE, "Invalid: '%s'", pszPath);
case RTDBGSYMCACHEFILETYPE_DIR_FILTER:
Cfg.pszFilter = RTPathFilename(pszPath);
/* fall thru */
case RTDBGSYMCACHEFILETYPE_DIR:
rc = rtDbgSymCacheAddDir(pszPath, &Cfg);
break;
case RTDBGSYMCACHEFILETYPE_DEBUG_FILE:
rc = rtDbgSymCacheAddDebugFile(pszPath, &Cfg);
break;
case RTDBGSYMCACHEFILETYPE_IMAGE_FILE:
rc = rtDbgSymCacheAddImageFile(pszPath, NULL /*pszExtraSuff*/, RTDBG_CACHE_UUID_MAP_DIR_IMAGES, &Cfg);
break;
case RTDBGSYMCACHEFILETYPE_DEBUG_BUNDLE:
case RTDBGSYMCACHEFILETYPE_IMAGE_BUNDLE:
{
size_t cchPath = strlen(pszPath);
size_t cchFilename = strlen(RTPathFilename(pszPath));
char szPathBuf[RTPATH_MAX];
if (cchPath < sizeof(szPathBuf))
{
memcpy(szPathBuf, pszPath, cchPath + 1);
if (enmType == RTDBGSYMCACHEFILETYPE_DEBUG_BUNDLE)
rc = rtDbgSymCacheAddDebugBundle(szPathBuf, cchPath - cchFilename, cchFilename, &Cfg);
else
{
RTDIRENTRYEX DirEntry;
rc = rtDbgSymCacheAddImageBundle(szPathBuf, cchPath - cchFilename, cchFilename, &DirEntry, &Cfg);
}
}
else
rc = RTMsgErrorRc(VERR_FILENAME_TOO_LONG, "Filename too long: '%s'", pszPath);
break;
}
case RTDBGSYMCACHEFILETYPE_IGNORE:
rc = RTMsgErrorRc(VERR_INVALID_PARAMETER, "Invalid file: '%s'", pszPath);
break;
}
return RT_SUCCESS(rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;
}
示例2: usbTestUsage
static void usbTestUsage(PRTSTREAM pStrm)
{
char szExec[RTPATH_MAX];
RTStrmPrintf(pStrm, "usage: %s [options]\n",
RTPathFilename(RTProcGetExecutablePath(szExec, sizeof(szExec))));
RTStrmPrintf(pStrm, "\n");
RTStrmPrintf(pStrm, "options: \n");
for (unsigned i = 0; i < RT_ELEMENTS(g_aCmdOptions); i++)
{
const char *pszHelp;
switch (g_aCmdOptions[i].iShort)
{
case 'h':
pszHelp = "Displays this help and exit";
break;
case 'd':
pszHelp = "Use the specified test device";
break;
default:
pszHelp = "Option undocumented";
break;
}
char szOpt[256];
RTStrPrintf(szOpt, sizeof(szOpt), "%s, -%c", g_aCmdOptions[i].pszLong, g_aCmdOptions[i].iShort);
RTStrmPrintf(pStrm, " %-20s%s\n", szOpt, pszHelp);
}
}
示例3: RTR3DECL
RTR3DECL(int) RTManifestWriteFilesBuf(void **ppvBuf, size_t *pcbSize, RTDIGESTTYPE enmDigestType, PRTMANIFESTTEST paFiles, size_t cFiles)
{
/* Validate input */
AssertPtrReturn(ppvBuf, VERR_INVALID_POINTER);
AssertPtrReturn(pcbSize, VERR_INVALID_POINTER);
AssertPtrReturn(paFiles, VERR_INVALID_POINTER);
AssertReturn(cFiles > 0, VERR_INVALID_PARAMETER);
const char *pcszDigestType;
switch (enmDigestType)
{
case RTDIGESTTYPE_CRC32: pcszDigestType = "CRC32"; break;
case RTDIGESTTYPE_CRC64: pcszDigestType = "CRC64"; break;
case RTDIGESTTYPE_MD5: pcszDigestType = "MD5"; break;
case RTDIGESTTYPE_SHA1: pcszDigestType = "SHA1"; break;
case RTDIGESTTYPE_SHA256: pcszDigestType = "SHA256"; break;
default: return VERR_INVALID_PARAMETER;
}
/* Calculate the size necessary for the memory buffer. */
size_t cbSize = 0;
size_t cbMaxSize = 0;
for (size_t i = 0; i < cFiles; ++i)
{
size_t cbTmp = strlen(RTPathFilename(paFiles[i].pszTestFile))
+ strlen(paFiles[i].pszTestDigest)
+ strlen(pcszDigestType)
+ 6;
cbMaxSize = RT_MAX(cbMaxSize, cbTmp);
cbSize += cbTmp;
}
/* Create the memory buffer */
void *pvBuf = RTMemAlloc(cbSize);
if (!pvBuf)
return VERR_NO_MEMORY;
/* Allocate a temporary string buffer. */
char *pszTmp = RTStrAlloc(cbMaxSize + 1);
if (!pszTmp)
{
RTMemFree(pvBuf);
return VERR_NO_MEMORY;
}
size_t cbPos = 0;
for (size_t i = 0; i < cFiles; ++i)
{
size_t cch = RTStrPrintf(pszTmp, cbMaxSize + 1, "%s (%s)= %s\n", pcszDigestType, RTPathFilename(paFiles[i].pszTestFile), paFiles[i].pszTestDigest);
memcpy(&((char*)pvBuf)[cbPos], pszTmp, cch);
cbPos += cch;
}
RTStrFree(pszTmp);
/* Results */
*ppvBuf = pvBuf;
*pcbSize = cbSize;
return VINF_SUCCESS;
}
示例4: RTPathFilename
/**
* Extract the extension pack name from the tarball path.
*
* @returns String containing the name on success, the caller must delete it.
* NULL if no valid name was found or if we ran out of memory.
* @param pszTarball The path to the tarball.
*/
RTCString *VBoxExtPackExtractNameFromTarballPath(const char *pszTarball)
{
/*
* Skip ahead to the filename part and count the number of characters
* that matches the criteria for a mangled extension pack name.
*/
const char *pszSrc = RTPathFilename(pszTarball);
if (!pszSrc)
return NULL;
size_t off = 0;
while (RT_C_IS_ALNUM(pszSrc[off]) || pszSrc[off] == '_')
off++;
/*
* Check min and max name limits.
*/
if ( off > VBOX_EXTPACK_NAME_MAX_LEN
|| off < VBOX_EXTPACK_NAME_MIN_LEN)
return NULL;
/*
* Return the unmangled name.
*/
return VBoxExtPackUnmangleName(pszSrc, off);
}
示例5: DECLCALLBACK
/**
* @callback_method_impl{FNDBGCCMD, The '.injecterror' command.}
*/
static DECLCALLBACK(int) pdmacEpFileErrorInject(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR pArgs, unsigned cArgs)
{
/*
* Validate input.
*/
DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM);
DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, -1, cArgs == 3);
DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, pArgs[0].enmType == DBGCVAR_TYPE_STRING);
DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 1, pArgs[1].enmType == DBGCVAR_TYPE_STRING);
DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 2, pArgs[2].enmType == DBGCVAR_TYPE_NUMBER);
PPDMASYNCCOMPLETIONEPCLASSFILE pEpClassFile;
pEpClassFile = (PPDMASYNCCOMPLETIONEPCLASSFILE)pUVM->pdm.s.apAsyncCompletionEndpointClass[PDMASYNCCOMPLETIONEPCLASSTYPE_FILE];
/* Syntax is "read|write <filename> <status code>" */
bool fWrite;
if (!RTStrCmp(pArgs[0].u.pszString, "read"))
fWrite = false;
else if (!RTStrCmp(pArgs[0].u.pszString, "write"))
fWrite = true;
else
return DBGCCmdHlpFail(pCmdHlp, pCmd, "invalid transfer direction '%s'", pArgs[0].u.pszString);
int32_t rcToInject = (int32_t)pArgs[2].u.u64Number;
if ((uint64_t)rcToInject != pArgs[2].u.u64Number)
return DBGCCmdHlpFail(pCmdHlp, pCmd, "The status code '%lld' is out of range", pArgs[0].u.u64Number);
/*
* Search for the matching endpoint.
*/
RTCritSectEnter(&pEpClassFile->Core.CritSect);
PPDMASYNCCOMPLETIONENDPOINTFILE pEpFile = (PPDMASYNCCOMPLETIONENDPOINTFILE)pEpClassFile->Core.pEndpointsHead;
while (pEpFile)
{
if (!RTStrCmp(pArgs[1].u.pszString, RTPathFilename(pEpFile->Core.pszUri)))
break;
pEpFile = (PPDMASYNCCOMPLETIONENDPOINTFILE)pEpFile->Core.pNext;
}
if (pEpFile)
{
/*
* Do the job.
*/
if (fWrite)
ASMAtomicXchgS32(&pEpFile->rcReqWrite, rcToInject);
else
ASMAtomicXchgS32(&pEpFile->rcReqRead, rcToInject);
DBGCCmdHlpPrintf(pCmdHlp, "Injected %Rrc into '%s' for %s\n",
(int)rcToInject, pArgs[1].u.pszString, pArgs[0].u.pszString);
}
RTCritSectLeave(&pEpClassFile->Core.CritSect);
if (!pEpFile)
return DBGCCmdHlpFail(pCmdHlp, pCmd, "No file with name '%s' found", pArgs[1].u.pszString);
return VINF_SUCCESS;
}
示例6: renderspu_SystemVBoxCreateWindow
GLboolean renderspu_SystemVBoxCreateWindow(VisualInfo *pVisInfo, GLboolean fShowIt, WindowInfo *pWinInfo)
{
CRASSERT(pVisInfo);
CRASSERT(pWinInfo);
/* VirtualBox is the only frontend which support 3D right now. */
char pszName[256];
if (RTProcGetExecutablePath(pszName, sizeof(pszName)))
/* Check for VirtualBox and VirtualBoxVM */
if (RTStrNICmp(RTPathFilename(pszName), "VirtualBox", 10) != 0)
return GL_FALSE;
pWinInfo->visual = pVisInfo;
pWinInfo->window = NULL;
pWinInfo->nativeWindow = NULL;
pWinInfo->currentCtx = NULL;
#ifdef __LP64__
NativeNSViewRef pParentWin = (NativeNSViewRef)render_spu_parent_window_id;
#else /* __LP64__ */
NativeNSViewRef pParentWin = (NativeNSViewRef)(uint32_t)render_spu_parent_window_id;
#endif /* __LP64__ */
cocoaViewCreate(&pWinInfo->window, pWinInfo, pParentWin, pVisInfo->visAttribs);
if (fShowIt)
renderspu_SystemShowWindow(pWinInfo, fShowIt);
return GL_TRUE;
}
示例7: RTDECL
RTDECL(int) RTCrX509Certificate_ReadFromFile(PRTCRX509CERTIFICATE pCertificate, const char *pszFilename, uint32_t fFlags,
PCRTASN1ALLOCATORVTABLE pAllocator, PRTERRINFO pErrInfo)
{
AssertReturn(!fFlags, VERR_INVALID_FLAGS);
PCRTCRPEMSECTION pSectionHead;
int rc = RTCrPemReadFile(pszFilename, 0, g_aCertificateMarkers, RT_ELEMENTS(g_aCertificateMarkers), &pSectionHead, pErrInfo);
if (RT_SUCCESS(rc))
{
RTCRX509CERTIFICATE TmpCert;
RTASN1CURSORPRIMARY PrimaryCursor;
RTAsn1CursorInitPrimary(&PrimaryCursor, pSectionHead->pbData, (uint32_t)RT_MIN(pSectionHead->cbData, UINT32_MAX),
pErrInfo, pAllocator, RTASN1CURSOR_FLAGS_DER, RTPathFilename(pszFilename));
rc = RTCrX509Certificate_DecodeAsn1(&PrimaryCursor.Cursor, 0, &TmpCert, "Cert");
if (RT_SUCCESS(rc))
{
rc = RTCrX509Certificate_CheckSanity(&TmpCert, 0, pErrInfo, "Cert");
if (RT_SUCCESS(rc))
{
rc = RTCrX509Certificate_Clone(pCertificate, &TmpCert, &g_RTAsn1DefaultAllocator);
if (RT_SUCCESS(rc))
{
if (pSectionHead->pNext || PrimaryCursor.Cursor.cbLeft)
rc = VINF_ASN1_MORE_DATA;
}
}
RTCrX509Certificate_Delete(&TmpCert);
}
RTCrPemFreeSections(pSectionHead);
}
return rc;
}
示例8: main
int main(int argc, char **argv)
{
RTTEST hTest;
int rc = RTTestInitAndCreate("tstRTFileGetSize-1", &hTest);
if (rc)
return rc;
RTTestBanner(hTest);
for (int i = 0; i < argc; i++)
{
char *pszNm = RTPathFilename(argv[i]);
if (!pszNm)
pszNm = argv[i];
test1(pszNm, argv[i]);
}
#ifdef RT_OS_WINDOWS
test1("//./PhysicalDrive0", "//./PhysicalDrive0");
test1("//./HarddiskVolume1", "//./HarddiskVolume1");
test1("//./null", "//./nul");
#else
test1("/dev/null", "/dev/null");
# ifdef RT_OS_LINUX
test1("/dev/sda", "/dev/sda");
test1("/dev/sda1", "/dev/sda1");
test1("/dev/sda5", "/dev/sda5");
# endif
#endif
/*
* Summary.
*/
return RTTestSummaryAndDestroy(hTest);
}
示例9: gzipOpenOutput
/**
* Opens the output file.
*
* @returns Command exit, error messages written using RTMsg*.
*
* @param pszFile The input filename.
* @param pOpts The options, szOutput will be filled in by this
* function on success.
* @param phVfsIos Where to return the output stream handle.
*
* @remarks This is actually not quite the way we need to do things.
*
* First of all, we need a GZIP file system stream for a real GZIP
* implementation, since there may be more than one file in the gzipped
* file.
*
* Second, we need to open the output files as we encounter files in the input
* file system stream. The gzip format contains timestamp and usually a
* filename, the default is to use this name (see the --no-name
* option).
*/
static RTEXITCODE gzipOpenOutput(const char *pszFile, PRTGZIPCMDOPTS pOpts, PRTVFSIOSTREAM phVfsIos)
{
int rc;
if (!strcmp(pszFile, "-") || pOpts->fStdOut)
{
strcpy(pOpts->szOutput, "-");
if ( !pOpts->fForce
&& !pOpts->fDecompress
&& gzipIsStdHandleATty(RTHANDLESTD_OUTPUT))
return RTMsgErrorExit(RTEXITCODE_SYNTAX,
"Yeah, right. I'm not writing any compressed data to the terminal without --force.\n");
rc = RTVfsIoStrmFromStdHandle(RTHANDLESTD_OUTPUT,
RTFILE_O_WRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE,
true /*fLeaveOpen*/,
phVfsIos);
if (RT_FAILURE(rc))
return RTMsgErrorExit(RTEXITCODE_FAILURE, "Error opening standard output: %Rrc", rc);
}
else
{
Assert(!RTVfsChainIsSpec(pszFile));
/* Construct an output filename. */
rc = RTStrCopy(pOpts->szOutput, sizeof(pOpts->szOutput), pszFile);
if (RT_FAILURE(rc))
return RTMsgErrorExit(RTEXITCODE_FAILURE, "Error constructing output filename: %Rrc", rc);
if (pOpts->fDecompress)
{
/** @todo take filename from archive? */
size_t cchSuff = strlen(pOpts->pszSuff); Assert(cchSuff > 0);
size_t cch = strlen(pOpts->szOutput);
if ( cch <= cchSuff
|| strcmp(&pOpts->szOutput[cch - cchSuff], pOpts->pszSuff))
return RTMsgErrorExit(RTEXITCODE_FAILURE, "Input file does not end with: '%s'", pOpts->pszSuff);
pOpts->szOutput[cch - cchSuff] = '\0';
if (!RTPathFilename(pOpts->szOutput))
return RTMsgErrorExit(RTEXITCODE_FAILURE, "Error constructing output filename: Input file name is all suffix.");
}
else
{
rc = RTStrCat(pOpts->szOutput, sizeof(pOpts->szOutput), pOpts->pszSuff);
if (RT_FAILURE(rc))
return RTMsgErrorExit(RTEXITCODE_FAILURE, "Error constructing output filename: %Rrc", rc);
}
/* Open the output file. */
uint32_t fOpen = RTFILE_O_WRITE | RTFILE_O_DENY_WRITE;
if (pOpts->fForce)
fOpen |= RTFILE_O_CREATE_REPLACE;
else
fOpen |= RTFILE_O_CREATE;
rc = RTVfsIoStrmOpenNormal(pOpts->szOutput, fOpen, phVfsIos);
if (RT_FAILURE(rc))
return RTMsgErrorExit(RTEXITCODE_FAILURE, "Error opening output file '%s': %Rrc", pOpts->szOutput, rc);
}
return RTEXITCODE_SUCCESS;
}
示例10: checkAbsoluteFilePath
/** Check that the string is an absolute path to a file or print an error. */
bool checkAbsoluteFilePath(const char *pcszName, const char *pcszValue)
{
if (RTPathFilename(pcszValue) && RTPathStartsWithRoot(pcszValue))
return true;
RTStrmPrintf(g_pStdErr, "%s: %s must be an absolute path of a file.\n", pcszName, pcszValue);
return false;
}
示例11: ComSafeArrayOut
STDMETHODIMP VFSExplorer::Exists(ComSafeArrayIn(IN_BSTR, aNames), ComSafeArrayOut(BSTR, aExists))
{
CheckComArgSafeArrayNotNull(aNames);
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
com::SafeArray<IN_BSTR> sfaNames(ComSafeArrayInArg(aNames));
std::list<BSTR> listExists;
for (size_t a=0; a < sfaNames.size(); ++a)
{
std::list<VFSExplorer::Data::DirEntry>::const_iterator it;
for (it = m->entryList.begin();
it != m->entryList.end();
++it)
{
const VFSExplorer::Data::DirEntry &entry = (*it);
if (entry.name == RTPathFilename(Utf8Str(sfaNames[a]).c_str()))
{
BSTR name;
Bstr tmp(sfaNames[a]); /* gcc-3.3 cruft */
tmp.cloneTo(&name);
listExists.push_back(name);
}
}
}
com::SafeArray<BSTR> sfaExists(listExists);
sfaExists.detachTo(ComSafeArrayOutArg(aExists));
return S_OK;
}
示例12: DECLCALLBACK
/**
* Delay inject callback.
*/
static DECLCALLBACK(int) pdmacEpFileDelayInject(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR pArgs, unsigned cArgs)
{
/*
* Validate input.
*/
DBGC_CMDHLP_REQ_VM_RET(pCmdHlp, pCmd, pVM);
DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, -1, cArgs == 3);
DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, pArgs[0].enmType == DBGCVAR_TYPE_STRING);
DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 1, pArgs[1].enmType == DBGCVAR_TYPE_STRING);
DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 2, pArgs[2].enmType == DBGCVAR_TYPE_NUMBER);
PPDMASYNCCOMPLETIONEPCLASSFILE pEpClassFile;
pEpClassFile = (PPDMASYNCCOMPLETIONEPCLASSFILE)pVM->pUVM->pdm.s.apAsyncCompletionEndpointClass[PDMASYNCCOMPLETIONEPCLASSTYPE_FILE];
/* Syntax is "read|write <filename> <status code>" */
bool fWrite;
if (!RTStrCmp(pArgs[0].u.pszString, "read"))
fWrite = false;
else if (!RTStrCmp(pArgs[0].u.pszString, "write"))
fWrite = true;
else
return DBGCCmdHlpFail(pCmdHlp, pCmd, "invalid transfer direction '%s'", pArgs[0].u.pszString);
uint32_t msDelay = (uint32_t)pArgs[2].u.u64Number;
if ((uint64_t)msDelay != pArgs[2].u.u64Number)
return DBGCCmdHlpFail(pCmdHlp, pCmd, "The delay '%lld' is out of range", pArgs[0].u.u64Number);
/*
* Search for the matching endpoint.
*/
RTCritSectEnter(&pEpClassFile->Core.CritSect);
PPDMASYNCCOMPLETIONENDPOINTFILE pEpFile = (PPDMASYNCCOMPLETIONENDPOINTFILE)pEpClassFile->Core.pEndpointsHead;
while (pEpFile)
{
if (!RTStrCmp(pArgs[1].u.pszString, RTPathFilename(pEpFile->Core.pszUri)))
break;
pEpFile = (PPDMASYNCCOMPLETIONENDPOINTFILE)pEpFile->Core.pNext;
}
if (pEpFile)
{
bool fXchg = ASMAtomicCmpXchgU32(&pEpFile->msDelay, msDelay, 0);
if (fXchg)
DBGCCmdHlpPrintf(pCmdHlp, "Injected delay of %u ms into '%s' for %s\n",
msDelay, pArgs[1].u.pszString, pArgs[0].u.pszString);
else
DBGCCmdHlpPrintf(pCmdHlp, "Another delay for '%s' is still active, ignoring\n",
pArgs[1].u.pszString);
}
RTCritSectLeave(&pEpClassFile->Core.CritSect);
if (!pEpFile)
return DBGCCmdHlpFail(pCmdHlp, pCmd, "No file with name '%s' found", pArgs[1].u.pszString);
return VINF_SUCCESS;
}
示例13: rtDbgSymCacheAddImageFileWorker
/**
* Worker that add the image file to the right place.
*
* @returns IPRT status code.
* @param pszPath Path to the image file.
* @param pCfg Configuration data.
* @param hLdrMod Image handle.
* @param pszExtraSuff Optional extra suffix. Mach-O dSYM hack.
* @param pszUuidMapDir Optional UUID map cache directory if the image
* should be mapped by UUID.
* The map is a Mac OS X debug feature supported by
* the two native debuggers gdb and lldb. Look for
* descriptions of DBGFileMappedPaths in the
* com.apple.DebugSymbols in the user defaults.
*/
static int rtDbgSymCacheAddImageFileWorker(const char *pszPath, PCRTDBGSYMCACHEADDCFG pCfg, RTLDRMOD hLdrMod,
const char *pszExtrSuff, const char *pszUuidMapDir)
{
/*
* Determine which subdirectory to put the files in.
*/
RTUUID Uuid;
PRTUUID pUuid = NULL;
int rc;
char szSubDir[48];
RTLDRFMT enmFmt = RTLdrGetFormat(hLdrMod);
switch (enmFmt)
{
case RTLDRFMT_MACHO:
{
rc = RTLdrQueryProp(hLdrMod, RTLDRPROP_UUID, &Uuid, sizeof(Uuid));
if (RT_FAILURE(rc))
return RTMsgErrorRc(rc, "Error quering image UUID from image '%s': %Rrc", pszPath, rc);
rc = RTUuidToStr(&Uuid, szSubDir, sizeof(szSubDir));
if (RT_FAILURE(rc))
return RTMsgErrorRc(rc, "Error convering UUID for image '%s' to string: %Rrc", pszPath, rc);
pUuid = &Uuid;
break;
}
case RTLDRFMT_PE:
{
uint32_t uTimestamp;
rc = RTLdrQueryProp(hLdrMod, RTLDRPROP_TIMESTAMP_SECONDS, &uTimestamp, sizeof(uTimestamp));
if (RT_FAILURE(rc))
return RTMsgErrorRc(rc, "Error quering timestamp from image '%s': %Rrc", pszPath, rc);
size_t cbImage = RTLdrSize(hLdrMod);
if (cbImage == ~(size_t)0)
return RTMsgErrorRc(rc, "Error quering size of image '%s': %Rrc", pszPath, rc);
RTStrPrintf(szSubDir, sizeof(szSubDir), "%08X%x", uTimestamp, cbImage);
break;
}
case RTLDRFMT_AOUT:
return RTMsgErrorRc(VERR_NOT_SUPPORTED, "Caching of a.out image has not yet been implemented: %s", pszPath);
case RTLDRFMT_ELF:
return RTMsgErrorRc(VERR_NOT_SUPPORTED, "Caching of ELF image has not yet been implemented: %s", pszPath);
case RTLDRFMT_LX:
return RTMsgErrorRc(VERR_NOT_SUPPORTED, "Caching of LX image has not yet been implemented: %s", pszPath);
default:
return RTMsgErrorRc(VERR_NOT_SUPPORTED, "Unknown loader format for '%s': %d", pszPath, enmFmt);
}
/*
* Now add it.
*/
return rtDbgSymCacheAddOneFile(pszPath, RTPathFilename(pszPath), pszExtrSuff,
szSubDir, pUuid, pszUuidMapDir, pCfg);
}
示例14: rtCreateTempValidateTemplate
static int rtCreateTempValidateTemplate(char *pszTemplate, char **ppszX,
unsigned *pcXes)
{
/*
* Validate input and count X'es.
*
* The X'es may be trailing, or they may be a cluster of 3 or more inside
* the file name.
*/
AssertPtr(pszTemplate);
AssertPtr(ppszX);
AssertPtr(pcXes);
unsigned cXes = 0;
char *pszX = strchr(pszTemplate, '\0');
if ( pszX != pszTemplate
&& pszX[-1] != 'X')
{
/* look inside the file name. */
char *pszFilename = RTPathFilename(pszTemplate);
if ( pszFilename
&& (size_t)(pszX - pszFilename) > 3)
{
char *pszXEnd = pszX - 1;
pszFilename += 3;
do
{
if ( pszXEnd[-1] == 'X'
&& pszXEnd[-2] == 'X'
&& pszXEnd[-3] == 'X')
{
pszX = pszXEnd - 3;
cXes = 3;
break;
}
} while (pszXEnd-- != pszFilename);
}
}
/* count them */
while ( pszX != pszTemplate
&& pszX[-1] == 'X')
{
pszX--;
cXes++;
}
/* fail if none found. */
if (!cXes)
{
AssertFailed();
return VERR_INVALID_PARAMETER;
}
*ppszX = pszX;
*pcXes = cXes;
return VINF_SUCCESS;
}
示例15: main
int main(int argc, char **argv)
{
RTEXITCODE rcExit = RTTestInitAndCreate(RTPathFilename(argv[0]),
&g_hTest);
if (rcExit != RTEXITCODE_SUCCESS)
return rcExit;
RTTestBanner(g_hTest);
testAPI(g_hTest);
return RTTestSummaryAndDestroy(g_hTest);
}