本文整理汇总了C++中BDirectory::Unset方法的典型用法代码示例。如果您正苦于以下问题:C++ BDirectory::Unset方法的具体用法?C++ BDirectory::Unset怎么用?C++ BDirectory::Unset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BDirectory
的用法示例。
在下文中一共展示了BDirectory::Unset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetInstallationLocationInfo
status_t
BDaemonClient::CreateTransaction(BPackageInstallationLocation location,
BActivationTransaction& _transaction, BDirectory& _transactionDirectory)
{
// get an info for the location
BInstallationLocationInfo info;
status_t error = GetInstallationLocationInfo(location, info);
if (error != B_OK)
return error;
// open admin directory
entry_ref entryRef;
entryRef.device = info.PackagesDirectoryRef().device;
entryRef.directory = info.PackagesDirectoryRef().node;
error = entryRef.set_name(PACKAGES_DIRECTORY_ADMIN_DIRECTORY);
if (error != B_OK)
return error;
BDirectory adminDirectory;
error = adminDirectory.SetTo(&entryRef);
if (error != B_OK)
return error;
// create a transaction directory
int uniqueId = 1;
BString directoryName;
for (;; uniqueId++) {
directoryName.SetToFormat("transaction-%d", uniqueId);
if (directoryName.IsEmpty())
return B_NO_MEMORY;
error = adminDirectory.CreateDirectory(directoryName,
&_transactionDirectory);
if (error == B_OK)
break;
if (error != B_FILE_EXISTS)
return error;
}
// init the transaction
error = _transaction.SetTo(location, info.ChangeCount(), directoryName);
if (error != B_OK) {
BEntry entry;
_transactionDirectory.GetEntry(&entry);
_transactionDirectory.Unset();
if (entry.InitCheck() == B_OK)
entry.Remove();
return error;
}
return B_OK;
}
示例2: equals
// MakeLinkedPathTest
void
SymLinkTest::MakeLinkedPathTest()
{
const char *dirLink = dirLinkname;
const char *fileLink = fileLinkname;
const char *relDirLink = relDirLinkname;
const char *relFileLink = relFileLinkname;
const char *cyclicLink1 = cyclicLinkname1;
const char *cyclicLink2 = cyclicLinkname2;
const char *existingDir = existingDirname;
const char *existingSuperDir = existingSuperDirname;
const char *existingFile = existingFilename;
const char *existingSuperFile = existingSuperFilename;
const char *nonExisting = nonExistingDirname;
BSymLink link;
BPath path;
// 1. MakeLinkedPath(const char*, BPath*)
// uninitialized
NextSubTest();
CPPUNIT_ASSERT( link.InitCheck() == B_NO_INIT );
CPPUNIT_ASSERT( equals(link.MakeLinkedPath("/boot", &path), B_BAD_ADDRESS,
B_FILE_ERROR) );
link.Unset();
path.Unset();
// existing absolute dir link
NextSubTest();
CPPUNIT_ASSERT( link.SetTo(dirLink) == B_OK );
CPPUNIT_ASSERT( link.MakeLinkedPath("/boot", &path)
== (ssize_t)strlen(existingDir) );
CPPUNIT_ASSERT( path.InitCheck() == B_OK );
CPPUNIT_ASSERT( string(existingDir) == path.Path() );
link.Unset();
path.Unset();
// existing absolute file link
NextSubTest();
CPPUNIT_ASSERT( link.SetTo(fileLink) == B_OK );
CPPUNIT_ASSERT( link.MakeLinkedPath("/boot", &path)
== (ssize_t)strlen(existingFile) );
CPPUNIT_ASSERT( path.InitCheck() == B_OK );
CPPUNIT_ASSERT( string(existingFile) == path.Path() );
link.Unset();
path.Unset();
// existing absolute cyclic link
NextSubTest();
CPPUNIT_ASSERT( link.SetTo(cyclicLink1) == B_OK );
CPPUNIT_ASSERT( link.MakeLinkedPath("/boot", &path)
== (ssize_t)strlen(cyclicLink2) );
CPPUNIT_ASSERT( path.InitCheck() == B_OK );
CPPUNIT_ASSERT( string(cyclicLink2) == path.Path() );
link.Unset();
path.Unset();
// existing relative dir link
NextSubTest();
BEntry entry;
BPath entryPath;
CPPUNIT_ASSERT( entry.SetTo(existingDir) == B_OK );
CPPUNIT_ASSERT( entry.GetPath(&entryPath) == B_OK );
CPPUNIT_ASSERT( link.SetTo(relDirLink) == B_OK );
CPPUNIT_ASSERT( link.MakeLinkedPath(existingSuperDir, &path)
== (ssize_t)strlen(entryPath.Path()) );
CPPUNIT_ASSERT( path.InitCheck() == B_OK );
CPPUNIT_ASSERT( entryPath == path );
link.Unset();
path.Unset();
entry.Unset();
entryPath.Unset();
// existing relative file link
NextSubTest();
CPPUNIT_ASSERT( entry.SetTo(existingFile) == B_OK );
CPPUNIT_ASSERT( entry.GetPath(&entryPath) == B_OK );
CPPUNIT_ASSERT( link.SetTo(relFileLink) == B_OK );
CPPUNIT_ASSERT( link.MakeLinkedPath(existingSuperFile, &path)
== (ssize_t)strlen(entryPath.Path()) );
CPPUNIT_ASSERT( path.InitCheck() == B_OK );
CPPUNIT_ASSERT( entryPath == path );
link.Unset();
path.Unset();
entry.Unset();
entryPath.Unset();
// bad args
NextSubTest();
CPPUNIT_ASSERT( link.SetTo(dirLink) == B_OK );
// R5: crashs, when passing a NULL path
#if !TEST_R5
CPPUNIT_ASSERT( link.MakeLinkedPath("/boot", NULL) == B_BAD_VALUE );
#endif
CPPUNIT_ASSERT( link.MakeLinkedPath((const char*)NULL, &path)
== B_BAD_VALUE );
// R5: crashs, when passing a NULL path
#if !TEST_R5
CPPUNIT_ASSERT( link.MakeLinkedPath((const char*)NULL, NULL)
== B_BAD_VALUE );
#endif
link.Unset();
path.Unset();
// 2. MakeLinkedPath(const BDirectory*, BPath*)
// uninitialized
NextSubTest();
//.........这里部分代码省略.........