本文整理汇总了C++中RTPrintf函数的典型用法代码示例。如果您正苦于以下问题:C++ RTPrintf函数的具体用法?C++ RTPrintf怎么用?C++ RTPrintf使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RTPrintf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
int rc = RTR3InitExe(argc, &argv, 0);
if (RT_FAILURE(rc))
return RTMsgInitFailure(rc);
/*
* Parse arguments up to the command and pass it on to the command handlers.
*/
typedef enum
{
VCUACTION_ADD_TRUSTED_PUBLISHER = 1000,
VCUACTION_REMOVE_TRUSTED_PUBLISHER,
VCUACTION_DISPLAY_ALL,
VCUACTION_END
} VCUACTION;
static const RTGETOPTDEF s_aOptions[] =
{
{ "--verbose", 'v', RTGETOPT_REQ_NOTHING },
{ "--quiet", 'q', RTGETOPT_REQ_NOTHING },
{ "add-trusted-publisher", VCUACTION_ADD_TRUSTED_PUBLISHER, RTGETOPT_REQ_NOTHING },
{ "remove-trusted-publisher", VCUACTION_REMOVE_TRUSTED_PUBLISHER, RTGETOPT_REQ_NOTHING },
{ "display-all", VCUACTION_DISPLAY_ALL, RTGETOPT_REQ_NOTHING },
};
RTGETOPTUNION ValueUnion;
RTGETOPTSTATE GetState;
RTGetOptInit(&GetState, argc, argv, s_aOptions, RT_ELEMENTS(s_aOptions), 1, 0);
while ((rc = RTGetOpt(&GetState, &ValueUnion)))
{
switch (rc)
{
case 'v':
g_cVerbosityLevel++;
break;
case 'q':
if (g_cVerbosityLevel > 0)
g_cVerbosityLevel--;
break;
case 'h':
showUsage(argv[0]);
return RTEXITCODE_SUCCESS;
case 'V':
RTPrintf("%sr%d\n", RTBldCfgVersion(), RTBldCfgRevision());
return RTEXITCODE_SUCCESS;
case VCUACTION_ADD_TRUSTED_PUBLISHER:
return cmdAddTrustedPublisher(argc - GetState.iNext + 1, argv + GetState.iNext - 1);
case VCUACTION_REMOVE_TRUSTED_PUBLISHER:
return cmdRemoveTrustedPublisher(argc - GetState.iNext + 1, argv + GetState.iNext - 1);
case VCUACTION_DISPLAY_ALL:
return cmdDisplayAll(argc - GetState.iNext + 1, argv + GetState.iNext - 1);
default:
return RTGetOptPrintError(rc, &ValueUnion);
}
}
RTMsgError("Missing command...");
showUsage(argv[0]);
return RTEXITCODE_SYNTAX;
}
示例2: bench
/**
* Method that does the actual resize of the guest framebuffer and
* then changes the SDL framebuffer setup.
*/
static void bench(unsigned long w, unsigned long h, unsigned long bpp)
{
Uint32 Rmask, Gmask, Bmask, Amask = 0;
Uint32 Rsize, Gsize, Bsize;
Uint32 newWidth, newHeight;
guGuestXRes = w;
guGuestYRes = h;
guGuestBpp = bpp;
RTPrintf("\n");
/* a different format we support directly? */
switch (guGuestBpp)
{
case 16:
{
Rmask = 0xF800;
Gmask = 0x07E0;
Bmask = 0x001F;
Amask = 0x0000;
Rsize = 5;
Gsize = 6;
Bsize = 5;
break;
}
case 24:
{
Rmask = 0x00FF0000;
Gmask = 0x0000FF00;
Bmask = 0x000000FF;
Amask = 0x00000000;
Rsize = 8;
Gsize = 8;
Bsize = 8;
break;
}
default:
Rmask = 0x00FF0000;
Gmask = 0x0000FF00;
Bmask = 0x000000FF;
Amask = 0x00000000;
Rsize = 8;
Gsize = 8;
Bsize = 8;
break;
}
int sdlFlags = SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL;
#ifdef VBOX_OPENGL
if (gfOpenGL)
sdlFlags |= SDL_OPENGL;
#endif
if (gfResizable)
sdlFlags |= SDL_RESIZABLE;
if (gfFullscreen)
sdlFlags |= SDL_FULLSCREEN;
/*
* Now we have to check whether there are video mode restrictions
*/
SDL_Rect **modes;
/* Get available fullscreen/hardware modes */
modes = SDL_ListModes(NULL, sdlFlags);
if (modes == NULL)
{
RTPrintf("Error: SDL_ListModes failed with message '%s'\n", SDL_GetError());
return;
}
/* -1 means that any mode is possible (usually non fullscreen) */
if (modes != (SDL_Rect **)-1)
{
/*
* according to the SDL documentation, the API guarantees that
* the modes are sorted from larger to smaller, so we just
* take the first entry as the maximum.
*/
guMaxScreenWidth = modes[0]->w;
guMaxScreenHeight = modes[0]->h;
}
else
{
/* no restriction */
guMaxScreenWidth = ~0;
guMaxScreenHeight = ~0;
}
newWidth = RT_MIN(guMaxScreenWidth, guGuestXRes);
newHeight = RT_MIN(guMaxScreenHeight, guGuestYRes);
/*
* Now set the screen resolution and get the surface pointer
* @todo BPP is not supported!
//.........这里部分代码省略.........
示例3: main
int main()
{
int cErrors = 0;
#define CHECK_EXPR(expr) \
do { bool const f = !!(expr); if (RT_UNLIKELY(!f)) { RTPrintf("tstStrSimplePattern(%d): %s!\n", __LINE__, #expr); cErrors++; } } while (0)
#define CHECK_EXPR_MSG(expr, msg) \
do { \
bool const f = !!(expr); \
if (RT_UNLIKELY(!f)) { \
RTPrintf("tstStrSimplePattern(%d): %s!\n", __LINE__, #expr); \
RTPrintf("tstStrSimplePattern: "); \
RTPrintf msg; \
++cErrors; \
} \
} while (0)
CHECK_EXPR(RTStrSimplePatternMatch("*", ""));
CHECK_EXPR(RTStrSimplePatternMatch("*", "asdfasdflkjasdlfkj"));
CHECK_EXPR(RTStrSimplePatternMatch("*?*?*?*?*", "asdfasdflkjasdlfkj"));
CHECK_EXPR(RTStrSimplePatternMatch("asdf??df", "asdfasdf"));
CHECK_EXPR(!RTStrSimplePatternMatch("asdf??dq", "asdfasdf"));
CHECK_EXPR(RTStrSimplePatternMatch("asdf*df", "asdfasdf"));
CHECK_EXPR(!RTStrSimplePatternMatch("asdf*dq", "asdfasdf"));
CHECK_EXPR(RTStrSimplePatternMatch("a*", "asdfasdf"));
CHECK_EXPR(RTStrSimplePatternMatch("a*f", "asdfasdf"));
CHECK_EXPR(!RTStrSimplePatternMatch("a*q", "asdfasdf"));
CHECK_EXPR(!RTStrSimplePatternMatch("a*q?", "asdfasdf"));
CHECK_EXPR(RTStrSimplePatternMatch("?*df", "asdfasdf"));
CHECK_EXPR(RTStrSimplePatternNMatch("*", 1, "", 0));
CHECK_EXPR(RTStrSimplePatternNMatch("*", ~(size_t)0, "", 0));
CHECK_EXPR(RTStrSimplePatternNMatch("*", ~(size_t)0, "", ~(size_t)0));
CHECK_EXPR(RTStrSimplePatternNMatch("*", 1, "asdfasdflkjasdlfkj", ~(size_t)0));
CHECK_EXPR(RTStrSimplePatternNMatch("*", ~(size_t)0, "asdfasdflkjasdlfkj", ~(size_t)0));
CHECK_EXPR(RTStrSimplePatternNMatch("*", 1, "asdfasdflkjasdlfkj", 3));
CHECK_EXPR(RTStrSimplePatternNMatch("*", 2, "asdfasdflkjasdlfkj", 10));
CHECK_EXPR(RTStrSimplePatternNMatch("*", 15, "asdfasdflkjasdlfkj", 10));
CHECK_EXPR(RTStrSimplePatternNMatch("*?*?*?*?*", 1, "asdfasdflkjasdlfkj", 128));
CHECK_EXPR(RTStrSimplePatternNMatch("*?*?*?*?*", 5, "asdfasdflkjasdlfkj", 0));
CHECK_EXPR(RTStrSimplePatternNMatch("*?*?*?*?*", 5, "asdfasdflkjasdlfkj", ~(size_t)0));
CHECK_EXPR(RTStrSimplePatternNMatch("*?*?*?*?*", ~(size_t)0, "asdfasdflkjasdlfkj", ~(size_t)0));
CHECK_EXPR(RTStrSimplePatternNMatch("asdf??df", 8, "asdfasdf", 8));
CHECK_EXPR(RTStrSimplePatternNMatch("asdf??df", ~(size_t)0, "asdfasdf", 8));
CHECK_EXPR(RTStrSimplePatternNMatch("asdf??df", ~(size_t)0, "asdfasdf", ~(size_t)0));
CHECK_EXPR(RTStrSimplePatternNMatch("asdf??df", 7, "asdfasdf", 7));
CHECK_EXPR(!RTStrSimplePatternNMatch("asdf??df", 7, "asdfasdf", 8));
CHECK_EXPR(!RTStrSimplePatternNMatch("asdf??dq", 8, "asdfasdf", 8));
CHECK_EXPR(RTStrSimplePatternNMatch("asdf??dq", 7, "asdfasdf", 7));
CHECK_EXPR(RTStrSimplePatternNMatch("asdf*df", 8, "asdfasdf", 8));
CHECK_EXPR(!RTStrSimplePatternNMatch("asdf*dq", 8, "asdfasdf", 8));
CHECK_EXPR(RTStrSimplePatternNMatch("a*", 10, "asdfasdf", 8));
CHECK_EXPR(RTStrSimplePatternNMatch("a*f", 3, "asdfasdf", ~(size_t)0));
CHECK_EXPR(!RTStrSimplePatternNMatch("a*q", 3, "asdfasdf", ~(size_t)0));
CHECK_EXPR(!RTStrSimplePatternNMatch("a*q?", 4, "asdfasdf", 9));
CHECK_EXPR(RTStrSimplePatternNMatch("?*df", 4, "asdfasdf", 8));
size_t offPattern;
CHECK_EXPR(RTStrSimplePatternMultiMatch("asdq|a*f|a??t", ~(size_t)0, "asdf", 4, NULL));
CHECK_EXPR(RTStrSimplePatternMultiMatch("asdq|a*f|a??t", ~(size_t)0, "asdf", 4, &offPattern));
CHECK_EXPR(offPattern == 5);
CHECK_EXPR(RTStrSimplePatternMultiMatch("asdq|a??t|a??f", ~(size_t)0, "asdf", 4, NULL));
CHECK_EXPR(RTStrSimplePatternMultiMatch("asdq|a??t|a??f", ~(size_t)0, "asdf", 4, &offPattern));
CHECK_EXPR(offPattern == 10);
CHECK_EXPR(RTStrSimplePatternMultiMatch("a*f|a??t|a??f", ~(size_t)0, "asdf", 4, NULL));
CHECK_EXPR(RTStrSimplePatternMultiMatch("a*f|a??t|a??f", ~(size_t)0, "asdf", 4, &offPattern));
CHECK_EXPR(offPattern == 0);
CHECK_EXPR(!RTStrSimplePatternMultiMatch("asdq|a??y|a??x", ~(size_t)0, "asdf", 4, NULL));
CHECK_EXPR(!RTStrSimplePatternMultiMatch("asdq|a??y|a??x", ~(size_t)0, "asdf", 4, &offPattern));
CHECK_EXPR(offPattern == ~(size_t)0);
CHECK_EXPR(RTStrSimplePatternMultiMatch("asdq|a*f|a??t", 9, "asdf", 4, NULL));
CHECK_EXPR(RTStrSimplePatternMultiMatch("asdq|a*f|a??t", 8, "asdf", 4, NULL));
CHECK_EXPR(RTStrSimplePatternMultiMatch("asdq|a*f|a??t", 7, "asdf", 4, NULL));
CHECK_EXPR(!RTStrSimplePatternMultiMatch("asdq|a*f|a??t", 6, "asdf", 4, NULL));
CHECK_EXPR(!RTStrSimplePatternMultiMatch("asdq|a*f|a??t", 5, "asdf", 4, NULL));
CHECK_EXPR(!RTStrSimplePatternMultiMatch("asdq|a*f|a??t", 4, "asdf", 4, NULL));
CHECK_EXPR(!RTStrSimplePatternMultiMatch("asdq|a*f|a??t", 3, "asdf", 4, NULL));
CHECK_EXPR(RTStrSimplePatternMultiMatch("asdf", 4, "asdf", 4, NULL));
CHECK_EXPR(RTStrSimplePatternMultiMatch("asdf|", 5, "asdf", 4, NULL));
/*
* Summary.
*/
if (!cErrors)
RTPrintf("tstStrToNum: SUCCESS\n");
else
RTPrintf("tstStrToNum: FAILURE - %d errors\n", cErrors);
return !!cErrors;
}
示例4: doOneFreeSpaceWipe
/**
* Does one free space wipe, using the given filename.
*
* @returns RTEXITCODE_SUCCESS on success, RTEXITCODE_FAILURE on failure (fully
* bitched).
* @param pszFilename The filename to use for wiping free space. Will be
* replaced and afterwards deleted.
* @param pvFiller The filler block buffer.
* @param cbFiller The size of the filler block buffer.
* @param cbMinLeftOpt When to stop wiping.
*/
static RTEXITCODE doOneFreeSpaceWipe(const char *pszFilename, void const *pvFiller, size_t cbFiller, uint64_t cbMinLeftOpt)
{
/*
* Open the file.
*/
RTEXITCODE rcExit = RTEXITCODE_SUCCESS;
RTFILE hFile = NIL_RTFILE;
int rc = RTFileOpen(&hFile, pszFilename,
RTFILE_O_WRITE | RTFILE_O_DENY_NONE | RTFILE_O_CREATE_REPLACE | (0775 << RTFILE_O_CREATE_MODE_SHIFT));
if (RT_SUCCESS(rc))
{
/*
* Query the amount of available free space. Figure out which API we should use.
*/
RTFOFF cbTotal = 0;
RTFOFF cbFree = 0;
rc = RTFileQueryFsSizes(hFile, &cbTotal, &cbFree, NULL, NULL);
bool const fFileHandleApiSupported = rc != VERR_NOT_SUPPORTED && rc != VERR_NOT_IMPLEMENTED;
if (!fFileHandleApiSupported)
rc = RTFsQuerySizes(pszFilename, &cbTotal, &cbFree, NULL, NULL);
if (RT_SUCCESS(rc))
{
RTPrintf("%s: %'9RTfoff MiB out of %'9RTfoff are free\n", pszFilename, cbFree / _1M, cbTotal / _1M);
/*
* Start filling up the free space, down to the last 32MB.
*/
uint64_t const nsStart = RTTimeNanoTS(); /* for speed calcs */
uint64_t nsStat = nsStart; /* for speed calcs */
uint64_t cbStatWritten = 0; /* for speed calcs */
RTFOFF const cbMinLeft = RT_MAX(cbMinLeftOpt, cbFiller * 2);
RTFOFF cbLeftToWrite = cbFree - cbMinLeft;
uint64_t cbWritten = 0;
uint32_t iLoop = 0;
while (cbLeftToWrite >= (RTFOFF)cbFiller)
{
rc = RTFileWrite(hFile, pvFiller, cbFiller, NULL);
if (RT_FAILURE(rc))
{
if (rc == VERR_DISK_FULL)
RTPrintf("%s: Disk full after writing %'9RU64 MiB\n", pszFilename, cbWritten / _1M);
else
rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "%s: Write error after %'RU64 bytes: %Rrc\n",
pszFilename, cbWritten, rc);
break;
}
/* Flush every now and then as we approach a completely full disk. */
if (cbLeftToWrite <= _1G && (iLoop & (cbLeftToWrite > _128M ? 15 : 3)) == 0)
RTFileFlush(hFile);
/*
* Advance and maybe recheck the amount of free space.
*/
cbWritten += cbFiller;
cbLeftToWrite -= (ssize_t)cbFiller;
iLoop++;
if ((iLoop & (16 - 1)) == 0 || cbLeftToWrite < _256M)
{
RTFOFF cbFreeUpdated;
if (fFileHandleApiSupported)
rc = RTFileQueryFsSizes(hFile, NULL, &cbFreeUpdated, NULL, NULL);
else
rc = RTFsQuerySizes(pszFilename, NULL, &cbFreeUpdated, NULL, NULL);
if (RT_SUCCESS(rc))
{
cbFree = cbFreeUpdated;
cbLeftToWrite = cbFree - cbMinLeft;
}
else
{
rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "%s: Failed to query free space after %'RU64 bytes: %Rrc\n",
pszFilename, cbWritten, rc);
break;
}
if ((iLoop & (512 - 1)) == 0)
{
uint64_t const nsNow = RTTimeNanoTS();
uint64_t cNsInterval = nsNow - nsStat;
uint64_t cbInterval = cbWritten - cbStatWritten;
uint64_t cbIntervalPerSec = cbInterval ? (uint64_t)(cbInterval / (cNsInterval / (double)RT_NS_1SEC)) : 0;
RTPrintf("%s: %'9RTfoff MiB out of %'9RTfoff are free after writing %'9RU64 MiB (%'5RU64 MiB/s)\n",
pszFilename, cbFree / _1M, cbTotal / _1M, cbWritten / _1M, cbIntervalPerSec / _1M);
nsStat = nsNow;
cbStatWritten = cbWritten;
}
}
}
//.........这里部分代码省略.........
示例5: PrintResult
void PrintResult(uint64_t u64Ticks, uint64_t u64MaxTicks, uint64_t u64MinTicks, unsigned cTimes, const char *pszOperation)
{
RTPrintf("tstPrfRT: %-32s %5lld / %5lld / %5lld ticks per call (%u calls %lld ticks)\n",
pszOperation, u64MinTicks, u64Ticks / (uint64_t)cTimes, u64MaxTicks, cTimes, u64Ticks);
}
示例6: handlerWipeFreeSpace
/**
* Wipes free space on one or more volumes by creating large files.
*/
static RTEXITCODE handlerWipeFreeSpace(int argc, char **argv)
{
/*
* Parse arguments.
*/
const char *apszDefFiles[2] = { "./wipefree.spc", NULL };
bool fAll = false;
uint32_t u32Filler = UINT32_C(0xf6f6f6f6);
uint64_t cbMinLeftOpt = _32M;
static RTGETOPTDEF const s_aOptions[] =
{
{ "--all", 'a', RTGETOPT_REQ_NOTHING },
{ "--filler", 'f', RTGETOPT_REQ_UINT32 },
{ "--min-free", 'm', RTGETOPT_REQ_UINT64 },
};
RTGETOPTSTATE State;
RTGetOptInit(&State, argc, argv, &s_aOptions[0], RT_ELEMENTS(s_aOptions), 1, RTGETOPTINIT_FLAGS_OPTS_FIRST);
RTGETOPTUNION ValueUnion;
int chOpt;
while ( (chOpt = RTGetOpt(&State, &ValueUnion)) != 0
&& chOpt != VINF_GETOPT_NOT_OPTION)
{
switch (chOpt)
{
case 'a':
fAll = true;
break;
case 'f':
u32Filler = ValueUnion.u32;
break;
case 'm':
cbMinLeftOpt = ValueUnion.u64;
break;
case 'h':
RTPrintf("usage: wipefrespace [options] [filename1 [..]]\n"
"\n"
"Options:\n"
" -a, --all\n"
" Try do the free space wiping on all seemingly relevant file systems.\n"
" Changes the meaning of the filenames "
" This is not yet implemented\n"
" -p, --filler <32-bit value>\n"
" What to fill the blocks we write with.\n"
" Default: 0xf6f6f6f6\n"
" -m, --min-free <64-bit byte count>\n"
" Specifies when to stop in terms of free disk space (in bytes).\n"
" Default: 32MB\n"
"\n"
"Zero or more names of files to do the free space wiping thru can be given.\n"
"When --all is NOT used, each of the files are used to do free space wiping on\n"
"the volume they will live on. However, when --all is in effect the files are\n"
"appended to the volume mountpoints and only the first that can be created will\n"
"be used. Files (used ones) will be removed when done.\n"
"\n"
"If no filename is given, the default is: %s\n"
, apszDefFiles[0]);
return RTEXITCODE_SUCCESS;
default:
return RTGetOptPrintError(chOpt, &ValueUnion);
}
}
char **papszFiles;
if (chOpt == 0)
papszFiles = (char **)apszDefFiles;
else
papszFiles = RTGetOptNonOptionArrayPtr(&State);
/*
* Allocate and prep a memory which we'll write over and over again.
*/
uint32_t cbFiller = _2M;
uint32_t *pu32Filler = (uint32_t *)RTMemPageAlloc(cbFiller);
while (!pu32Filler)
{
cbFiller <<= 1;
if (cbFiller >= _4K)
pu32Filler = (uint32_t *)RTMemPageAlloc(cbFiller);
else
return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTMemPageAlloc failed for sizes between 4KB and 2MB!\n");
}
for (uint32_t i = 0; i < cbFiller / sizeof(pu32Filler[0]); i++)
pu32Filler[i] = u32Filler;
/*
* Do the requested work.
*/
RTEXITCODE rcExit = RTEXITCODE_SUCCESS;
if (!fAll)
{
for (uint32_t iFile = 0; papszFiles[iFile] != NULL; iFile++)
{
RTEXITCODE rcExit2 = doOneFreeSpaceWipe(papszFiles[iFile], pu32Filler, cbFiller, cbMinLeftOpt);
if (rcExit2 != RTEXITCODE_SUCCESS && rcExit == RTEXITCODE_SUCCESS)
rcExit = rcExit2;
//.........这里部分代码省略.........
示例7: handlerCpuHwVirt
/** Print the 'true' if VT-x or AMD-v is supported, 'false' it not. */
static RTEXITCODE handlerCpuHwVirt(int argc, char **argv)
{
NOREF(argc); NOREF(argv);
int cch = RTPrintf(isHwVirtSupported() != HWVIRTTYPE_NONE ? "true\n" : "false\n");
return cch > 0 ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;
}
示例8: RTCmdRmDir
static RTEXITCODE RTCmdRmDir(unsigned cArgs, char **papszArgs)
{
/*
* Parse the command line.
*/
static const RTGETOPTDEF s_aOptions[] =
{
/* operations */
{ "--parents", 'p', RTGETOPT_REQ_NOTHING },
{ "--ignore-fail-on-non-empty", 'F', RTGETOPT_REQ_NOTHING },
{ "--ignore-non-existing", 'E', RTGETOPT_REQ_NOTHING },
{ "--always-use-vfs-chain-api", 'A', RTGETOPT_REQ_NOTHING },
{ "--verbose", 'v', RTGETOPT_REQ_NOTHING },
};
RTGETOPTSTATE GetState;
int rc = RTGetOptInit(&GetState, cArgs, papszArgs, s_aOptions, RT_ELEMENTS(s_aOptions), 1,
RTGETOPTINIT_FLAGS_OPTS_FIRST);
if (RT_FAILURE(rc))
return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTGetOpt failed: %Rrc", rc);
RTCMDRMDIROPTS Opts;
Opts.fVerbose = false;
Opts.fParents = false;
Opts.fIgnoreNotEmpty = false;
Opts.fIgnoreNonExisting = false;
Opts.fAlwaysUseChainApi = false;
RTGETOPTUNION ValueUnion;
while ( (rc = RTGetOpt(&GetState, &ValueUnion)) != 0
&& rc != VINF_GETOPT_NOT_OPTION)
{
switch (rc)
{
case 'p':
Opts.fParents = true;
break;
case 'v':
Opts.fVerbose = true;
break;
case 'A':
Opts.fAlwaysUseChainApi = true;
break;
case 'E':
Opts.fIgnoreNonExisting = true;
break;
case 'F':
Opts.fIgnoreNotEmpty = true;
break;
case 'h':
RTPrintf("Usage: %s [options] <dir> [..]\n"
"\n"
"Removes empty directories.\n"
"\n"
"Options:\n"
" -p, --parent\n"
" Remove specified parent directories too.\n"
" -F, --ignore-fail-on-non-empty\n"
" Do not fail if a directory is not empty, just ignore it.\n"
" This is really handy with the -p option.\n"
" -E, --ignore-non-existing\n"
" Do not fail if a specified directory is not there.\n"
" -v, --verbose\n"
" Tell which directories get remove.\n"
" -A, --always-use-vfs-chain-api\n"
" Always use the VFS API.\n"
, papszArgs[0]);
return RTEXITCODE_SUCCESS;
case 'V':
RTPrintf("%sr%d\n", RTBldCfgVersion(), RTBldCfgRevision());
return RTEXITCODE_SUCCESS;
default:
return RTGetOptPrintError(rc, &ValueUnion);
}
}
/*
* No files means error.
*/
if (rc != VINF_GETOPT_NOT_OPTION)
return RTMsgErrorExit(RTEXITCODE_FAILURE, "No directories specified.\n");
/*
* Work thru the specified dirs.
*/
RTEXITCODE rcExit = RTEXITCODE_SUCCESS;
while (rc == VINF_GETOPT_NOT_OPTION)
{
if (Opts.fParents)
rc = rtCmdRmDirOneWithParents(&Opts, ValueUnion.psz);
else
rc = rtCmdRmDirOne(&Opts, ValueUnion.psz);
//.........这里部分代码省略.........
示例9: VbglR3SeamlessSetCap
int VbglR3SeamlessSetCap(bool bState)
{
RTPrintf("%s\n", bState ? "Seamless capability set"
: "Seamless capability unset");
return true;
}
示例10: VbglR3CtlFilterMask
int VbglR3CtlFilterMask(uint32_t u32OrMask, uint32_t u32NotMask)
{
RTPrintf("IRQ filter mask changed. Or mask: 0x%x. Not mask: 0x%x\n",
u32OrMask, u32NotMask);
return true;
}
示例11: main
int main(int argc, char* argv[])
{
int rcErrors = 0;
/*
* Initialize the runtime.
*/
RTR3InitAndSUPLib();
#ifndef AUTO_TEST_ARGS
if (argc < 2)
{
RTPrintf("syntax: %s command [args]\n"
"\n"
"command Command to run under child process in fork.\n"
"[args] Arguments to command.\n", argv[0]);
return 1;
}
#endif
/*
* Create empty VM.
*/
RTPrintf(TESTCASE ": Initializing...\n");
PVM pVM;
int rc = VMR3Create(1, NULL, NULL, NULL, NULL, NULL, &pVM);
if (RT_SUCCESS(rc))
{
/*
* Do testing.
*/
int iCowTester = 0;
char cCowTester = 'a';
#ifndef AUTO_TEST_ARGS
int cArgs = argc - 1;
char **ppszArgs = &argv[1];
#else
int cArgs = 2;
char *ppszArgs[3];
ppszArgs[0] = (char *)"/bin/sleep";
ppszArgs[1] = (char *)"3";
ppszArgs[2] = NULL;
#endif
RTPrintf(TESTCASE ": forking current process...\n");
pid_t pid = fork();
if (pid < 0)
{
/* Bad. fork() failed! */
RTPrintf(TESTCASE ": error: fork() failed.\n");
rcErrors++;
}
else if (pid == 0)
{
/*
* The child process.
* Write to some local variables to trigger copy-on-write if it's used.
*/
RTPrintf(TESTCASE ": running child process...\n");
RTPrintf(TESTCASE ": writing local variables...\n");
iCowTester = 2;
cCowTester = 'z';
RTPrintf(TESTCASE ": calling execv() with command-line:\n");
for (int i = 0; i < cArgs; i++)
RTPrintf(TESTCASE ": ppszArgs[%d]=%s\n", i, ppszArgs[i]);
execv(ppszArgs[0], ppszArgs);
RTPrintf(TESTCASE ": error: execv() returned to caller. errno=%d.\n", errno);
_exit(-1);
}
else
{
/*
* The parent process.
* Wait for child & run VMM test to ensure things are fine.
*/
int result;
while (waitpid(pid, &result, 0) < 0)
;
if (!WIFEXITED(result) || WEXITSTATUS(result) != 0)
{
RTPrintf(TESTCASE ": error: failed to run child process. errno=%d\n", errno);
rcErrors++;
}
if (rcErrors == 0)
{
RTPrintf(TESTCASE ": fork() returned fine.\n");
RTPrintf(TESTCASE ": testing VM after fork.\n");
VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)VMMDoTest, 1, pVM);
STAMR3Dump(pVM, "*");
}
}
if (rcErrors > 0)
RTPrintf(TESTCASE ": error: %d error(s) during fork(). Cannot proceed to test the VM.\n");
else
RTPrintf(TESTCASE ": fork() and VM test, SUCCESS.\n");
//.........这里部分代码省略.........
示例12: main
int main()
{
RTR3InitExeNoArguments(0);
/*
* Just a simple testcase.
*/
RTPrintf("tstOnce: TESTING - smoke...\n");
RTONCE Once1 = RTONCE_INITIALIZER;
g_fOnceCB1 = false;
int rc = RTOnce(&Once1, Once1CB, (void *)1);
if (rc != VINF_SUCCESS)
RTPrintf("tstOnce: ERROR - Once1, 1 failed, rc=%Rrc\n", rc);
g_fOnceCB1 = false;
rc = RTOnce(&Once1, Once1CB, (void *)1);
if (rc != VINF_SUCCESS)
RTPrintf("tstOnce: ERROR - Once1, 2 failed, rc=%Rrc\n", rc);
/*
* Throw a bunch of threads up against a init once thing.
*/
RTPrintf("tstOnce: TESTING - bunch of threads...\n");
/* create the semaphore they'll be waiting on. */
rc = RTSemEventMultiCreate(&g_hEventMulti);
if (RT_FAILURE(rc))
{
RTPrintf("tstOnce: FATAL ERROR - RTSemEventMultiCreate returned %Rrc\n", rc);
return 1;
}
/* create the threads */
RTTHREAD aThreads[32];
for (unsigned i = 0; i < RT_ELEMENTS(aThreads); i++)
{
char szName[16];
RTStrPrintf(szName, sizeof(szName), "ONCE2-%d\n", i);
rc = RTThreadCreate(&aThreads[i], Once2Thread, NULL, 0, RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, szName);
if (RT_FAILURE(rc))
{
RTPrintf("tstOnce: ERROR - failed to create thread #%d\n", i);
g_cErrors++;
}
}
/* kick them off and yield */
rc = RTSemEventMultiSignal(g_hEventMulti);
if (RT_FAILURE(rc))
{
RTPrintf("tstOnce: FATAL ERROR - RTSemEventMultiSignal returned %Rrc\n", rc);
return 1;
}
RTThreadYield();
/* wait for all of them to finish up, 30 seconds each. */
for (unsigned i = 0; i < RT_ELEMENTS(aThreads); i++)
if (aThreads[i] != NIL_RTTHREAD)
{
int rc2;
rc = RTThreadWait(aThreads[i], 30*1000, &rc2);
if (RT_FAILURE(rc))
{
RTPrintf("tstOnce: ERROR - RTThreadWait on thread #%u returned %Rrc\n", i, rc);
g_cErrors++;
}
else if (RT_FAILURE(rc2))
{
RTPrintf("tstOnce: ERROR - Thread #%u returned %Rrc\n", i, rc2);
g_cErrors++;
}
}
/*
* Summary.
*/
if (!g_cErrors)
RTPrintf("tstOnce: SUCCESS\n");
else
RTPrintf("tstOnce: FAILURE - %d errors\n", g_cErrors);
return !!g_cErrors;
}
示例13: main
//.........这里部分代码省略.........
TST_CHECK_RC(USBFilterSetNumExpression(&Flt1, USBFILTERIDX_VENDOR_ID, "42|1|0x1111", true));
TST_CHECK_EXPR(USBFilterMatch(&Flt1, &Dev));
TST_CHECK_RC(USBFilterSetNumExpression(&Flt1, USBFILTERIDX_VENDOR_ID, "42|0x1111|1", true));
TST_CHECK_EXPR(USBFilterMatch(&Flt1, &Dev));
TST_CHECK_RC(USBFilterSetNumExpression(&Flt1, USBFILTERIDX_VENDOR_ID, "0x1111|42|1", true));
TST_CHECK_EXPR(USBFilterMatch(&Flt1, &Dev));
TST_CHECK_RC(USBFilterSetNumExpression(&Flt1, USBFILTERIDX_VENDOR_ID, "0x1112|42|1", true));
TST_CHECK_EXPR(!USBFilterMatch(&Flt1, &Dev));
TST_CHECK_RC(USBFilterSetNumExpression(&Flt1, USBFILTERIDX_VENDOR_ID, "39-59|0x256-0x101f|0xfffff-0xf000|0x1000-0x2000", true));
TST_CHECK_EXPR(USBFilterMatch(&Flt1, &Dev));
TST_CHECK_RC(USBFilterSetNumExpression(&Flt1, USBFILTERIDX_VENDOR_ID, "0x000256-0x0101f|0xf000-0xfffff|0x000008000-0x2000|39-59", true));
TST_CHECK_EXPR(!USBFilterMatch(&Flt1, &Dev));
TST_CHECK_RC(USBFilterSetNumExpression(&Flt1, USBFILTERIDX_VENDOR_ID, "| | \t \t\t| 0x256 - 0x101f | 0xf000 - 0xfeff\t| 0x1000 -\t0x6000 | 1- 0512", true));
TST_CHECK_EXPR(USBFilterMatch(&Flt1, &Dev));
TST_CHECK_RC(USBFilterSetNumExpression(&Flt1, USBFILTERIDX_VENDOR_ID, "| | \t \t\t| 0x256 - 0x101f | 0xf000 - 0xfeff\t| 0x1112 -\t0x6000 | 1- 0512", true));
TST_CHECK_EXPR(!USBFilterMatch(&Flt1, &Dev));
USBFilterDelete(&Flt1);
/*
* string overflow
*/
struct
{
uint64_t u64Pre;
USBFILTER Flt;
uint64_t u64Post;
} sOf;
sOf.u64Pre = sOf.u64Post = UINT64_C(0x1234567887654321);
USBFilterInit(&sOf.Flt, USBFILTERTYPE_CAPTURE);
TST_CHECK_EXPR(sOf.u64Pre == UINT64_C(0x1234567887654321)); TST_CHECK_EXPR(sOf.u64Post == UINT64_C(0x1234567887654321));
AssertCompileMemberSize(USBFILTER, achStrTab, 256);
TST_CHECK_EXPR(USBFilterSetStringExact(&sOf.Flt, USBFILTERIDX_SERIAL_NUMBER_STR, &g_szString256[0], true, false ) == VERR_BUFFER_OVERFLOW);
TST_CHECK_EXPR(sOf.u64Pre == UINT64_C(0x1234567887654321)); TST_CHECK_EXPR(sOf.u64Post == UINT64_C(0x1234567887654321));
TST_CHECK_EXPR(USBFilterSetStringExact(&sOf.Flt, USBFILTERIDX_SERIAL_NUMBER_STR, &g_szString256[1], true, false ) == VERR_BUFFER_OVERFLOW);
TST_CHECK_EXPR(sOf.u64Pre == UINT64_C(0x1234567887654321)); TST_CHECK_EXPR(sOf.u64Post == UINT64_C(0x1234567887654321));
TST_CHECK_EXPR(USBFilterSetStringExact(&sOf.Flt, USBFILTERIDX_SERIAL_NUMBER_STR, &g_szString256[2], true, false ) == VINF_SUCCESS);
TST_CHECK_EXPR(sOf.u64Pre == UINT64_C(0x1234567887654321)); TST_CHECK_EXPR(sOf.u64Post == UINT64_C(0x1234567887654321));
TST_CHECK_EXPR(USBFilterSetStringExact(&sOf.Flt, USBFILTERIDX_SERIAL_NUMBER_STR, &g_szString256[3], true, false ) == VINF_SUCCESS);
TST_CHECK_EXPR(sOf.u64Pre == UINT64_C(0x1234567887654321)); TST_CHECK_EXPR(sOf.u64Post == UINT64_C(0x1234567887654321));
/* 0 + 1 */
TST_CHECK_EXPR(USBFilterSetStringExact(&sOf.Flt, USBFILTERIDX_SERIAL_NUMBER_STR, "", true, false ) == VINF_SUCCESS);
TST_CHECK_EXPR(sOf.u64Pre == UINT64_C(0x1234567887654321)); TST_CHECK_EXPR(sOf.u64Post == UINT64_C(0x1234567887654321));
TST_CHECK_EXPR(USBFilterSetStringExact(&sOf.Flt, USBFILTERIDX_PRODUCT_STR, &g_szString256[2], true, false ) == VINF_SUCCESS);
TST_CHECK_EXPR(sOf.u64Pre == UINT64_C(0x1234567887654321)); TST_CHECK_EXPR(sOf.u64Post == UINT64_C(0x1234567887654321));
TST_CHECK_EXPR(USBFilterSetStringExact(&sOf.Flt, USBFILTERIDX_PRODUCT_STR, &g_szString256[1], true, false ) == VERR_BUFFER_OVERFLOW);
TST_CHECK_EXPR(sOf.u64Pre == UINT64_C(0x1234567887654321)); TST_CHECK_EXPR(sOf.u64Post == UINT64_C(0x1234567887654321));
/* 0 + 2 */
TST_CHECK_EXPR(USBFilterSetStringExact(&sOf.Flt, USBFILTERIDX_PRODUCT_STR, &g_szString128[2], true, false ) == VINF_SUCCESS);
TST_CHECK_EXPR(sOf.u64Pre == UINT64_C(0x1234567887654321)); TST_CHECK_EXPR(sOf.u64Post == UINT64_C(0x1234567887654321));
TST_CHECK_EXPR(USBFilterSetStringExact(&sOf.Flt, USBFILTERIDX_SERIAL_NUMBER_STR, &g_szString128[1], true, false ) == VINF_SUCCESS);
TST_CHECK_EXPR(sOf.u64Pre == UINT64_C(0x1234567887654321)); TST_CHECK_EXPR(sOf.u64Post == UINT64_C(0x1234567887654321));
/* 3 */
TST_CHECK_EXPR(USBFilterSetStringExact(&sOf.Flt, USBFILTERIDX_SERIAL_NUMBER_STR, &g_szString64[0], true, false ) == VINF_SUCCESS);
TST_CHECK_EXPR(sOf.u64Pre == UINT64_C(0x1234567887654321)); TST_CHECK_EXPR(sOf.u64Post == UINT64_C(0x1234567887654321));
TST_CHECK_EXPR(USBFilterSetStringExact(&sOf.Flt, USBFILTERIDX_PRODUCT_STR, &g_szString64[0], true, false ) == VINF_SUCCESS);
TST_CHECK_EXPR(sOf.u64Pre == UINT64_C(0x1234567887654321)); TST_CHECK_EXPR(sOf.u64Post == UINT64_C(0x1234567887654321));
TST_CHECK_EXPR(USBFilterSetStringExact(&sOf.Flt, USBFILTERIDX_MANUFACTURER_STR, &g_szString128[4], true, false ) == VINF_SUCCESS);
TST_CHECK_EXPR(USBFilterSetStringExact(&sOf.Flt, USBFILTERIDX_MANUFACTURER_STR, &g_szString128[4], true, false ) == VINF_SUCCESS);
TST_CHECK_EXPR(USBFilterSetStringExact(&sOf.Flt, USBFILTERIDX_MANUFACTURER_STR, &g_szString128[3], true, false ) == VERR_BUFFER_OVERFLOW);
TST_CHECK_EXPR(sOf.u64Pre == UINT64_C(0x1234567887654321)); TST_CHECK_EXPR(sOf.u64Post == UINT64_C(0x1234567887654321));
/*
* Check for a string replacement bug.
*/
USBFILTER Dev2;
USBFilterInit(&Dev2, USBFILTERTYPE_CAPTURE);
TST_CHECK_EXPR(USBFilterSetNumExact(&Dev2, USBFILTERIDX_VENDOR_ID, 0x19b6, true) == VINF_SUCCESS);
TST_CHECK_EXPR(USBFilterSetNumExact(&Dev2, USBFILTERIDX_PRODUCT_ID, 0x1024, true) == VINF_SUCCESS);
TST_CHECK_EXPR(USBFilterSetNumExact(&Dev2, USBFILTERIDX_DEVICE_REV, 0x0141, true) == VINF_SUCCESS);
TST_CHECK_EXPR(USBFilterSetNumExact(&Dev2, USBFILTERIDX_DEVICE_CLASS, 0, true) == VINF_SUCCESS);
TST_CHECK_EXPR(USBFilterSetNumExact(&Dev2, USBFILTERIDX_DEVICE_SUB_CLASS, 0, true) == VINF_SUCCESS);
TST_CHECK_EXPR(USBFilterSetNumExact(&Dev2, USBFILTERIDX_DEVICE_PROTOCOL, 0, true) == VINF_SUCCESS);
TST_CHECK_EXPR(USBFilterSetNumExact(&Dev2, USBFILTERIDX_PORT, 0x1, true) == VINF_SUCCESS);
TST_CHECK_EXPR(USBFilterSetStringExact(&Dev2, USBFILTERIDX_MANUFACTURER_STR, "Generic", true, false ) == VINF_SUCCESS);
TST_CHECK_EXPR(USBFilterSetStringExact(&Dev2, USBFILTERIDX_PRODUCT_STR, "Mass Storage Device", true, false ) == VINF_SUCCESS);
TST_CHECK_EXPR(USBFilterSetStringExact(&Dev2, USBFILTERIDX_MANUFACTURER_STR, "YBU1PPRS", true, false ) == VINF_SUCCESS);
TST_CHECK_EXPR(USBFilterGetNum(&Dev2, USBFILTERIDX_VENDOR_ID) == 0x19b6);
TST_CHECK_EXPR(USBFilterGetNum(&Dev2, USBFILTERIDX_PRODUCT_ID) == 0x1024);
TST_CHECK_EXPR(USBFilterGetNum(&Dev2, USBFILTERIDX_DEVICE_REV) == 0x0141);
TST_CHECK_EXPR(USBFilterGetNum(&Dev2, USBFILTERIDX_DEVICE_CLASS) == 0);
TST_CHECK_EXPR(USBFilterGetNum(&Dev2, USBFILTERIDX_DEVICE_SUB_CLASS) == 0);
TST_CHECK_EXPR(USBFilterGetNum(&Dev2, USBFILTERIDX_DEVICE_PROTOCOL) == 0);
TST_CHECK_EXPR(USBFilterGetNum(&Dev2, USBFILTERIDX_PORT) == 1);
/*
* Summary.
*/
if (!cErrors)
RTPrintf(TESTCASE ": SUCCESS\n");
else
RTPrintf(TESTCASE ": FAILURE - %d errors\n", cErrors);
return !!cErrors;
}
示例14: supSvcWinCreate
/**
* Handle the 'create' action.
*
* @returns 0 or 1.
* @param argc The action argument count.
* @param argv The action argument vector.
*/
static int supSvcWinCreate(int argc, char **argv)
{
/*
* Parse the arguments.
*/
bool fVerbose = false;
static const RTOPTIONDEF s_aOptions[] =
{
{ "--verbose", 'v', RTGETOPT_REQ_NOTHING }
};
int iArg = 0;
int ch;
RTGETOPTUNION Value;
while ((ch = RTGetOpt(argc, argv, s_aOptions, RT_ELEMENTS(s_aOptions), &iArg, &Value)))
switch (ch)
{
case 'v': fVerbose = true; break;
default: return supSvcDisplayGetOptError("create", ch, argc, argv, iArg, &Value);
}
if (iArg != argc)
return supSvcDisplayTooManyArgsError("create", argc, argv, iArg);
/*
* Create the service.
*/
int rc = 1;
SC_HANDLE hSCM = supSvcWinOpenSCManager("create", SC_MANAGER_CREATE_SERVICE); /*SC_MANAGER_ALL_ACCESS*/
if (hSCM)
{
char szExecPath[MAX_PATH];
if (GetModuleFileName(NULL /* the executable */, szExecPath, sizeof(szExecPath)))
{
if (fVerbose)
RTPrintf("Creating the %s service, binary \"%s\"...\n",
SUPSVC_SERVICE_NAME, szExecPath); /* yea, the binary name isn't UTF-8, but wtf. */
SC_HANDLE hSvc = CreateService(hSCM, /* hSCManager */
SUPSVC_SERVICE_NAME, /* lpServiceName */
SUPSVC_SERVICE_DISPLAY_NAME, /* lpDisplayName */
SERVICE_CHANGE_CONFIG | SERVICE_QUERY_STATUS | SERVICE_QUERY_CONFIG, /* dwDesiredAccess */
SERVICE_WIN32_OWN_PROCESS, /* dwServiceType ( | SERVICE_INTERACTIVE_PROCESS? ) */
SERVICE_DEMAND_START/*_AUTO*/, /* dwStartType */
SERVICE_ERROR_NORMAL, /* dwErrorControl */
szExecPath, /* lpBinaryPathName */
NULL, /* lpLoadOrderGroup */
NULL, /* lpdwTagId */
NULL, /* lpDependencies */
NULL, /* lpServiceStartName (=> LocalSystem) */
NULL); /* lpPassword */
if (hSvc)
{
RTPrintf("Successfully created the %s service.\n", SUPSVC_SERVICE_NAME);
/** @todo Set the service description or it'll look weird in the vista service manager.
* Anything else that should be configured? Start access or something? */
rc = 0;
CloseServiceHandle(hSvc);
}
else
{
DWORD err = GetLastError();
switch (err)
{
case ERROR_SERVICE_EXISTS:
supSvcDisplayError("create - The service already exists.\n");
break;
default:
supSvcDisplayError("create - CreateService failed, err=%d.\n", GetLastError());
break;
}
}
CloseServiceHandle(hSvc);
}
else
supSvcDisplayError("create - Failed to obtain the executable path: %d\n", GetLastError());
}
return rc;
}
示例15: rtCmdRmDirOneWithParents
/**
* Create one directory and any missing parent directories.
*
* @returns exit code
* @param pOpts The mkdir option.
* @param pszDir The path to the new directory.
*/
static int rtCmdRmDirOneWithParents(RTCMDRMDIROPTS const *pOpts, const char *pszDir)
{
/* We need a copy we can work with here. */
char *pszCopy = RTStrDup(pszDir);
if (!pszCopy)
return RTMsgErrorExitFailure("Out of string memory!");
int rc;
if (!pOpts->fAlwaysUseChainApi && !RTVfsChainIsSpec(pszDir) )
{
size_t cchCopy = strlen(pszCopy);
do
{
rc = RTDirRemove(pszCopy);
if (RT_SUCCESS(rc))
{
if (pOpts->fVerbose)
RTPrintf("%s\n", pszCopy);
}
else if ((rc == VERR_PATH_NOT_FOUND || rc == VERR_FILE_NOT_FOUND) && pOpts->fIgnoreNonExisting)
rc = VINF_SUCCESS;
else
{
if ((rc == VERR_DIR_NOT_EMPTY || rc == VERR_SHARING_VIOLATION) && pOpts->fIgnoreNotEmpty)
rc = VINF_SUCCESS;
else
RTMsgError("Failed to remove directory '%s': %Rrc", pszCopy, rc);
break;
}
/* Strip off a component. */
while (cchCopy > 0 && RTPATH_IS_SLASH(pszCopy[cchCopy - 1]))
cchCopy--;
while (cchCopy > 0 && !RTPATH_IS_SLASH(pszCopy[cchCopy - 1]))
cchCopy--;
while (cchCopy > 0 && RTPATH_IS_SLASH(pszCopy[cchCopy - 1]))
cchCopy--;
pszCopy[cchCopy] = '\0';
} while (cchCopy > 0);
}
else
{
/*
* Strip the final path element from the pszDir spec.
*/
char *pszFinalPath;
char *pszSpec;
uint32_t offError;
rc = RTVfsChainSplitOffFinalPath(pszCopy, &pszSpec, &pszFinalPath, &offError);
if (RT_SUCCESS(rc))
{
/*
* Open the root director/whatever.
*/
RTERRINFOSTATIC ErrInfo;
RTVFSDIR hVfsBaseDir;
if (pszSpec)
{
rc = RTVfsChainOpenDir(pszSpec, 0 /*fOpen*/, &hVfsBaseDir, &offError, RTErrInfoInitStatic(&ErrInfo));
if (RT_FAILURE(rc))
RTVfsChainMsgError("RTVfsChainOpenDir", pszSpec, rc, offError, &ErrInfo.Core);
else if (!pszFinalPath)
pszFinalPath = RTStrEnd(pszSpec, RTSTR_MAX);
}
else if (!RTPathStartsWithRoot(pszFinalPath))
{
rc = RTVfsDirOpenNormal(".", 0 /*fOpen*/, &hVfsBaseDir);
if (RT_FAILURE(rc))
RTMsgError("Failed to open '.' (for %s): %Rrc", rc, pszFinalPath);
}
else
{
char *pszRoot = pszFinalPath;
pszFinalPath = RTPathSkipRootSpec(pszFinalPath);
char const chSaved = *pszFinalPath;
*pszFinalPath = '\0';
rc = RTVfsDirOpenNormal(pszRoot, 0 /*fOpen*/, &hVfsBaseDir);
*pszFinalPath = chSaved;
if (RT_FAILURE(rc))
RTMsgError("Failed to open root dir for '%s': %Rrc", rc, pszRoot);
}
/*
* Walk the path component by component, starting at the end.
*/
if (RT_SUCCESS(rc))
{
size_t cchFinalPath = strlen(pszFinalPath);
while (RT_SUCCESS(rc) && cchFinalPath > 0)
{
rc = RTVfsDirRemoveDir(hVfsBaseDir, pszFinalPath, 0 /*fFlags*/);
if (RT_SUCCESS(rc))
{
//.........这里部分代码省略.........