本文整理汇总了C++中OsPath::append方法的典型用法代码示例。如果您正苦于以下问题:C++ OsPath::append方法的具体用法?C++ OsPath::append怎么用?C++ OsPath::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OsPath
的用法示例。
在下文中一共展示了OsPath::append方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Path
OsPath SipXecsService::Path(DirectoryType pathType, const char* fileName)
{
OsPath path;
const char* dirPath;
if ( (dirPath = getenv(pathType)) )
{
OsSysLog::add(FAC_KERNEL, PRI_NOTICE,
"SipXecsService::Path type '%s' overridden by environment to '%s'",
pathType, dirPath);
}
else
{
dirPath = defaultDir(pathType);
}
path.append(dirPath);
const char slash = OsPath::separator(0);
const char lastPathChar = path(path.length()-1);
if (fileName && *fileName != '\000')
{
// Add the file name
// make sure there is exactly one separator between the directory and the file
if ( slash != lastPathChar
&& slash != fileName[0]
)
{
// neither has separator - add one
path.append(OsPath::separator);
}
else if ( slash == lastPathChar
&& slash == fileName[0]
)
{
// both have the separator - take one off so there's only one
path.remove(path.length()-1);
}
path.append(fileName);
}
// There is no file name, so make sure the returned directory name does not
// end in a separator
else if ( slash == lastPathChar )
{
path.remove(path.length()-1);
}
OsSysLog::add(FAC_KERNEL, PRI_DEBUG,
"SipXecsService::Path('%s', '%s') returning '%s'",
pathType, fileName ? fileName : "", path.data() );
return path;
}
示例2: testRemoveTree
void testRemoveTree()
{
OsStatus stat;
OsPath level1dir = mRootPath + OsPath::separator + "level1";
OsPath level2dir = level1dir + OsPath::separator + "level2";
OsPath level3dir = level2dir + OsPath::separator + "level3";
stat = OsFileSystem::createDir(level1dir);
CPPUNIT_ASSERT(stat == OS_SUCCESS);
stat = OsFileSystem::createDir(level2dir);
CPPUNIT_ASSERT(stat == OS_SUCCESS);
stat = OsFileSystem::createDir(level3dir);
CPPUNIT_ASSERT(stat == OS_SUCCESS);
OsPath filename;
//now create the files under each dir
for (int loop = 0; loop < 30;loop++)
{
UtlString levelStr = "level1_";
filename = level1dir + OsPath::separator + levelStr;
if (loop > 9)
{
levelStr = "level2_";
filename = level2dir + OsPath::separator + levelStr;
}
if (loop > 19)
{
levelStr = "level3_";
filename = level3dir + OsPath::separator + levelStr;
}
char buf[10];
sprintf(buf,"%d",loop);
filename.append(buf);
OsFile *tmpfile = new OsFile(filename);
tmpfile->touch();
delete tmpfile;
}
//now delete the tree
OsPath delPath(level1dir);
stat = OsFileSystem::remove(delPath, FALSE, TRUE);
CPPUNIT_ASSERT_MESSAGE("Should fail to delete recursively", stat != OS_SUCCESS);
KNOWN_BUG("INTERMITTENT failures", "XECS-1588");
stat = OsFileSystem::remove(delPath, TRUE, TRUE);
CPPUNIT_ASSERT_MESSAGE("Should succeed to delete recursively", stat == OS_SUCCESS);
}
示例3: createTestDir
void OsTestUtilities::createTestDir(OsPath& root)
{
OsStatus stat;
OsFileSystem::getWorkingDirectory(root);
root.append(OsPath::separator).append("OsFileSystemTest");
if (OsFileSystem::exists(root))
{
removeTestDir(root);
}
stat = OsFileSystem::createDir(root);
CPPUNIT_ASSERT_MESSAGE("setup root test dir", stat == OS_SUCCESS);
}
示例4: createTestDir
void OsTestUtilities::createTestDir(OsPath& root)
{
OsStatus stat;
#ifdef ANDROID
root = "/sdcard";
#else
OsFileSystem::getWorkingDirectory(root);
#endif
printf("Test dir root: %s\n", root.data());
root.append(OsPath::separator).append("OsFileSystemTest");
if (OsFileSystem::exists(root))
{
removeTestDir(root);
}
stat = OsFileSystem::createDir(root);
CPPUNIT_ASSERT_MESSAGE("setup root test dir", stat == OS_SUCCESS);
}