当前位置: 首页>>代码示例>>C++>>正文


C++ BEntry::Exists方法代码示例

本文整理汇总了C++中BEntry::Exists方法的典型用法代码示例。如果您正苦于以下问题:C++ BEntry::Exists方法的具体用法?C++ BEntry::Exists怎么用?C++ BEntry::Exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BEntry的用法示例。


在下文中一共展示了BEntry::Exists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

void
TBarWindow::MenusBeginning()
{
	BPath path;
	entry_ref ref;
	BEntry entry;

	if (GetDeskbarSettingsDirectory(path) == B_OK
		&& path.Append(kDeskbarMenuEntriesFileName) == B_OK
		&& entry.SetTo(path.Path(), true) == B_OK
		&& entry.Exists()
		&& entry.GetRef(&ref) == B_OK) {
		sDeskbarMenu->SetNavDir(&ref);
	} else if (GetDeskbarDataDirectory(path) == B_OK
		&& path.Append(kDeskbarMenuEntriesFileName) == B_OK
		&& entry.SetTo(path.Path(), true) == B_OK
		&& entry.Exists()
		&& entry.GetRef(&ref) == B_OK) {
		sDeskbarMenu->SetNavDir(&ref);
	} else {
		//	this really should never happen
		TRESPASS();
		return;
	}

	sDeskbarMenu->ResetTargets();

	fShowingMenu = true;
	BWindow::MenusBeginning();
}
开发者ID:looncraz,项目名称:haiku,代码行数:30,代码来源:BarWindow.cpp

示例2: if

status_t
InstalledPackageInfo::Uninstall()
{
	if (fStatus != B_OK)
		return fStatus;

	BString *iter;
	uint32 i, count = fInstalledItems.CountItems();
	BEntry entry;
	status_t ret;

	// Try to remove all entries that are present in the list
	for (i = 0; i < count; i++) {
		iter = static_cast<BString *>(fInstalledItems.ItemAt(count - i - 1));
		fprintf(stderr, "Removing: %s (%ld/%ld)\n", iter->String(), i, count);
		ret = entry.SetTo(iter->String());
		if (ret == B_BUSY) {
			// The entry's directory is locked - wait a few cycles for it to
			// unlock itself
			int32 tries = 0;
			for (tries = 0; tries < P_BUSY_TRIES; tries++) {
				ret = entry.SetTo(iter->String());
				if (ret != B_BUSY)
					break;
				// Wait a moment
				usleep(1000);
			}
		}

		if (ret == B_ENTRY_NOT_FOUND)
			continue;
		else if (ret != B_OK) {
			fStatus = B_ERROR;
			return fStatus;
		}

		fprintf(stderr, "...we continue\n");

		if (entry.Exists() && entry.Remove() != B_OK) {
			fprintf(stderr, "\n%s\n", strerror(ret));
			fStatus = B_ERROR;
			return fStatus;
		}
		fInstalledItems.RemoveItem(count - i - 1);
	}

	if (entry.SetTo(fPathToInfo.Path()) != B_OK) {
		fStatus = B_ERROR;
		return fStatus;
	}
	if (entry.Exists() && entry.Remove() != B_OK) {
		fStatus = B_ERROR;
		return fStatus;
	}

	return fStatus;
}
开发者ID:mmanley,项目名称:Antares,代码行数:57,代码来源:InstalledPackageInfo.cpp

示例3:

status_t 
ZKWindow::MakeSettingsFolder	(void)
{
	PRINT(("ZKWindow::MakeSettingsFolder()\n"));

	status_t	status;
	BPath		path;
	if ((status = find_directory(B_USER_SETTINGS_DIRECTORY, & path)) != B_OK)
		return status;
	
	BEntry 		entry	(path.Path());

	// settings
	if (entry.Exists()	==	false	||	entry.IsDirectory()	==	false)	
		return B_ERROR;
	
	BDirectory	mother	(path.Path());
	BDirectory	baby;
	
	// Kirilla
	path.SetTo(path.Path(), "Kirilla");
	entry.SetTo(path.Path());
	if (! entry.Exists())
	{
		status	=	mother.CreateDirectory("Kirilla", & baby);
		if (status != B_OK && status != B_FILE_EXISTS)				return status;
	}
	else 
		if (! entry.IsDirectory())
			return B_FILE_EXISTS;
	
	if ((status = mother.SetTo(path.Path())) != B_OK)			return status;

	// ZooKeeper
	path.SetTo(path.Path(), "ZooKeeper");
	entry.SetTo(path.Path());
	if (! entry.Exists())
	{
		status	=	mother.CreateDirectory("ZooKeeper", & baby);
		if (status != B_OK && status != B_FILE_EXISTS)				return status;
	}
	else 
		if (! entry.IsDirectory())
			return B_FILE_EXISTS;
	
	if ((status = mother.SetTo(path.Path())) != B_OK)			return status;

	entry.SetTo(path.Path());
	if (entry.Exists()	&&	entry.IsDirectory())	return B_OK;
	else											return B_ERROR;
}
开发者ID:HaikuArchives,项目名称:ZooKeeper,代码行数:51,代码来源:ZKWindow.cpp

示例4: path

status_t
ScreenshotWindow::_SaveScreenshot()
{
	if (!fScreenshot || !fLastSelectedPath)
		return B_ERROR;

	BPath path(_GetDirectory());

	if (path == NULL)
		return B_ERROR;

	path.Append(fNameControl->Text());

	BEntry entry;
	entry.SetTo(path.Path());

	if (entry.Exists()) {
		BAlert* overwriteAlert = new BAlert(
			B_TRANSLATE("overwrite"),
			B_TRANSLATE("This file already exists.\n Are you sure you would "
				"like to overwrite it?"),
			B_TRANSLATE("Cancel"),
			B_TRANSLATE("Overwrite"),
			NULL, B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);

		overwriteAlert->SetShortcut(0, B_ESCAPE);

		if (overwriteAlert->Go() == 0)
			return B_CANCELED;
	}

	return fUtility.Save(fScreenshot, path.Path(), fImageFileType);
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:33,代码来源:ScreenshotWindow.cpp

示例5: file

void
TReplicantTray::InitAddOnSupport()
{
	// list to maintain refs to each rep added/deleted
	fItemList = new BList();
	BPath path;

	if (find_directory(B_USER_SETTINGS_DIRECTORY, &path, true) == B_OK) {
		path.Append(kReplicantSettingsFile);

		BFile file(path.Path(), B_READ_ONLY);
		if (file.InitCheck() == B_OK) {
			status_t result;
			BEntry entry;
			int32 id;
			BString path;
			if (fAddOnSettings.Unflatten(&file) == B_OK) {
				for (int32 i = 0; fAddOnSettings.FindString(kReplicantPathField,
					i, &path) == B_OK; i++) {
					if (entry.SetTo(path.String()) == B_OK && entry.Exists()) {
						result = LoadAddOn(&entry, &id, false);
					} else
						result = B_ENTRY_NOT_FOUND;

					if (result != B_OK) {
						fAddOnSettings.RemoveData(kReplicantPathField, i);
						--i;
					}
				}
			}
		}
	}
}
开发者ID:RTOSkit,项目名称:haiku,代码行数:33,代码来源:StatusView.cpp

示例6: startModel

bool
BNavMenu::StartBuildingItemList()
{
	BEntry entry;

	if (fNavDir.device < 0 || entry.SetTo(&fNavDir) != B_OK
		|| !entry.Exists()) 
		return false;

	fItemList = new BObjectList<BMenuItem>(50);

	fIteratingDesktop = false;
	
	BDirectory parent;
	status_t status = entry.GetParent(&parent);

	// if ref is the root item then build list of volume root dirs
	fFlags = uint8((fFlags & ~kVolumesOnly) | (status == B_ENTRY_NOT_FOUND ? kVolumesOnly : 0));
	if (fFlags & kVolumesOnly)
		return true;
		
	Model startModel(&entry, true);
	if (startModel.InitCheck() != B_OK || !startModel.IsContainer()) 
		return false;

	if (startModel.IsQuery()) 
		fContainer = new QueryEntryListCollection(&startModel);
	else if (FSIsDeskDir(&entry)) {
		fIteratingDesktop = true;
		fContainer = DesktopPoseView::InitDesktopDirentIterator(0, startModel.EntryRef());
		AddRootItemsIfNeeded();
	} else if (FSIsTrashDir(&entry)) {
		// the trash window needs to display a union of all the
		// trash folders from all the mounted volumes
		BVolumeRoster volRoster;
		volRoster.Rewind();
		BVolume volume;
		fContainer = new EntryIteratorList();
		
		while (volRoster.GetNextVolume(&volume) == B_OK) {
			if (!volume.IsPersistent())
				continue;
			
			BDirectory trashDir;
			
			if (FSGetTrashDir(&trashDir, volume.Device()) == B_OK)
				dynamic_cast<EntryIteratorList *>(fContainer)->
					AddItem(new DirectoryEntryList(trashDir));
		}
	} else
		fContainer = new DirectoryEntryList(*dynamic_cast<BDirectory *>
			(startModel.Node()));
	
	if (fContainer == NULL || fContainer->InitCheck() != B_OK)
		return false;

	fContainer->Rewind();

	return true;
}
开发者ID:Ithamar,项目名称:cosmoe,代码行数:60,代码来源:NavMenu.cpp

示例7: SetPath

void InfoStrView::SetPath (const char *path)
{
	/* Store the given directory path in "itemPath". If the path is that of a file, it normalizes the path
		and gets its parent folder path and stores it in "itemPath"
		TODO: Accept a bool parameter "isFolder" to overcome the problem specified in the "else" part */
	DeAllocPath();
		
	BEntry entry (path, false);				/* Question: Must we traverse the link here ?? */
	if (entry.Exists() == true)
	{
		if (entry.IsFile() || entry.IsSymLink())
		{
			BEntry parentDir;
			entry.GetParent (&parentDir);
			
			BPath dirPath;
			parentDir.GetPath (&dirPath);
			AllocPath (dirPath.Path());
		}
		else								/* Means it's a directory */
		{
			AllocPath (path);
		}
	}
	else									/* Problem: Assume its a file NOT a directory */
	{
		BPath parentPath;
		BPath dirPath (path);
		dirPath.GetParent (&parentPath);
		
		AllocPath (parentPath.Path());
	}
}
开发者ID:puckipedia,项目名称:FilWip,代码行数:33,代码来源:InfoStrView.cpp

示例8:

// _GetSettingsDirPath
status_t
NetFSServer::_GetSettingsDirPath(BPath* path, bool create)
{
	// get the user settings directory
	BPath settingsDir;
	status_t error = find_directory(B_USER_SETTINGS_DIRECTORY, &settingsDir,
		create);
	if (error != B_OK)
		RETURN_ERROR(error);

	// create our subdir, if not existing and desired
	error = path->SetTo(settingsDir.Path(), kSettingsDirName);
	if (error != B_OK)
		RETURN_ERROR(error);
	BEntry bEntry;
	if (create
		&& (FDManager::SetEntry(&bEntry, settingsDir.Path()) != B_OK
			|| !bEntry.Exists())) {
		error = create_directory(path->Path(), S_IRWXU | S_IRWXG | S_IRWXO);
		if (error != B_OK)
			RETURN_ERROR(error);
	}

	return B_OK;
}
开发者ID:luciang,项目名称:haiku,代码行数:26,代码来源:NetFSServer.cpp

示例9: pathEntry

/*!	\brief Unmounts the volume.

	The volume can of course only be unmounted, if it currently is mounted.

	\param unmountFlags Currently only \c B_FORCE_UNMOUNT is defined, which
		   forces the partition to be unmounted, even if there are still
		   open FDs. Be careful using this flag -- you risk the user's data.

	\return \c B_OK, if everything went fine, another error code otherwise.
*/
status_t
BPartition::Unmount(uint32 unmountFlags)
{
	if (!IsMounted())
		return B_BAD_VALUE;

	// get the partition path
	BPath path;
	status_t status = GetMountPoint(&path);
	if (status != B_OK)
		return status;

	// unmount
	status = fs_unmount_volume(path.Path(), unmountFlags);

	// update object, if successful
	if (status == B_OK) {
		status = Device()->Update();

		// Check if we created this mount point on the fly.
		// If so, clean it up.
		BPath markerPath = path;
		markerPath.Append(skAutoCreatePrefix);
		BEntry pathEntry (markerPath.Path());
		if (pathEntry.InitCheck() == B_OK && pathEntry.Exists()) {
			rmdir(markerPath.Path());
			rmdir(path.Path());
		}
	}

	return status;
}
开发者ID:mmanley,项目名称:Antares,代码行数:42,代码来源:Partition.cpp

示例10: file

/*!	\brief		Perform the desired activity
 *		\details		This function is the central function of the activity mechanism.
 *						However, it does not display the notification message - mainly because
 *						it has no idea about the Event it belongs to, therefore it doesn't know
 *						the Event's name, category, and can't handle the "Snooze" message.
 *		\param[in]	in		Pointer to the \c Activity to be performed.
 */
void			ActivityData::PerformActivity( ActivityData* in )
{
	if ( !in ) { return; }
	
	BEntry		entry;
	entry_ref	fileRef, appRef;
	BPath			path;
	BString		tempString, anotherTempString;
	int			thread_id;
	
	// The notification will be displayed separately

	// Run a program
	if ( in->GetProgram( &path, &tempString ) )
	{
		entry.SetTo( path.Path(), true );		// Find the application to run
		if ( ( entry.InitCheck() == B_OK )			&&		// The initialization passed
		     ( entry.Exists() )							&&		// The entry exists
		     ( entry.GetPath( &path ) == B_OK ) )			// Got path to file (which may be not what the user entered)		
		{
			entry.Unset();		// Don't need the entry anymore
			anotherTempString.SetTo( path.Path() );
			anotherTempString << ' ';
			tempString.Prepend( anotherTempString );
		
				// Launch the program!	
			thread_id = fork();
			if ( thread_id == 0 ) {
				system( tempString.String() );
			}
		}
	}
	
	// Play a sound file
	if ( in->GetSound( &path ) ) {
		entry.SetTo( path.Path(), true );		// Find the file to play
		if ( ( entry.InitCheck() == B_OK ) 			&&		// The initialization passed
			  ( entry.Exists() )							&&		// The file exists
			  ( entry.GetRef( &fileRef ) == B_OK ) &&		// Got the reference to the file
			  ( be_roster->Launch( &fileRef ) == B_OK ) )	// Launched the file!
		{
			entry.Unset();	// Close the file descriptor
			// Launch was already performed
		}
	}

}	// <-- end of function ActivityData::PerformActivity
开发者ID:BackupTheBerlios,项目名称:haiku-pim-svn,代码行数:54,代码来源:ActivityData.cpp

示例11: catch

//------------------------------------------------------------------------------
bool	is_asst_installed()
{
	bool	aInstalled = true;
	BEntry	aEntry;

	try {
		aEntry.SetTo(asst_install_path(FOLDER_NAME_ASST_SPY).c_str(), true);
		if ( !aEntry.Exists() )
			throw B_ERROR;
		aEntry.SetTo(asst_install_path(FOLDER_NAME_ASST_PASTE_SENDER).c_str(), true);
		if ( !aEntry.Exists() )
			throw B_ERROR;
	} catch (...) {
		aInstalled = false;
	}
	return aInstalled;	
}
开发者ID:BackupTheBerlios,项目名称:textbank,代码行数:18,代码来源:Common.cpp

示例12: BEntry

bool
check_exists(BString db_path) {
  BString local_path = db_to_local_filepath(db_path);
  BEntry entry = BEntry(local_path.String());
  bool init = entry.InitCheck() == B_OK;
  bool exists = entry.Exists();
  printf("init:%d,exists:%d\n",init,exists);
  return init && exists;
}
开发者ID:astrieanna,项目名称:haiku-dropbox-client,代码行数:9,代码来源:HaikuDropbox.cpp

示例13: entry

status_t
StyledEditApp::OpenDocument(entry_ref* ref, BMessage* message)
{
	// traverse eventual symlink
	BEntry entry(ref, true);
	entry.GetRef(ref);

	if (entry.IsDirectory()) {
		BPath path(&entry);
		fprintf(stderr,
			"Can't open directory \"%s\" for editing.\n",
			path.Path());
		return B_ERROR;
	}

	BEntry parent;
	entry.GetParent(&parent);

	if (!entry.Exists() && !parent.Exists()) {
		fprintf(stderr,
			"Can't create file. Missing parent directory.\n");
		return B_ERROR;
	}

	BWindow* window = NULL;
	StyledEditWindow* document = NULL;

	for (int32 index = 0; ; index++) {
		window = WindowAt(index);
		if (window == NULL)
			break;

		document = dynamic_cast<StyledEditWindow*>(window);
		if (document == NULL)
			continue;

		if (document->IsDocumentEntryRef(ref)) {
			if (document->Lock()) {
				document->Activate();
				document->Unlock();
				if (message != NULL)
					document->PostMessage(message);
				return B_OK;
			}
		}
	}

	document = new StyledEditWindow(sWindowRect, ref, fOpenAsEncoding);
	cascade();

	if (message != NULL)
		document->PostMessage(message);

	fWindowCount++;

	return B_OK;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:57,代码来源:StyledEditApp.cpp

示例14: BMessage

/**** constructeur ****/
CPreferenceFile::CPreferenceFile(const char *fileName,const char *basePath,const char *extendedPath)
: BMessage(C_PREFERENCE_MSG)
{
	BPath		path;
	BEntry		settingPathEntry;
	
	// par defaut on a pas reussi
	_state = B_ERROR;

	// trouver si le repertoire Settings existe
	if(find_directory(B_USER_SETTINGS_DIRECTORY,&path)!=B_OK)
		path.SetTo("/boot/home/config/settings");

	// verifier si le repertoire MeTOS existe
	// sinon le creer
	_filePath = path.Path();
	_filePath << "/" << basePath;
	settingPathEntry.SetTo(_filePath.String());
	if(!(settingPathEntry.Exists()))
		create_directory(_filePath.String(),00777);

	// on est dans un sous repertoire
	if(extendedPath!=NULL)
	{
		BString		extendedPathString;
		
		extendedPathString = extendedPath;
		if(extendedPathString.Length()>0)
		{
			_filePath << "/";
			_filePath << extendedPath;
			settingPathEntry.SetTo(_filePath.String());
			if(!(settingPathEntry.Exists()))
				create_directory(_filePath.String(),00777);
		}
	}
	
	_filePath << "/";
	_filePath << fileName;
	_filePath << ".prefs";
	_state = B_OK;
}
开发者ID:HaikuArchives,项目名称:BeNetTris,代码行数:43,代码来源:CPreferenceFile.cpp

示例15: new

// _LoadSettings
status_t
NetFSServer::_LoadSettings()
{
	// get the settings file path
	BPath filePath;
	status_t error = _GetSettingsFilePath(&filePath, false);
	if (error != B_OK)
		RETURN_ERROR(error);

	// if existing load the settings
	BEntry bEntry;
	if (FDManager::SetEntry(&bEntry, filePath.Path()) == B_OK
		&& bEntry.Exists()) {
		return B_ENTRY_NOT_FOUND;
	}

	// open the settings file
	BFile file;
	error = FDManager::SetFile(&file, filePath.Path(), B_READ_ONLY);
	if (error != B_OK)
		RETURN_ERROR(error);

	// read the settings
	BMessage settings;
	error = settings.Unflatten(&file);
	if (error != B_OK)
		RETURN_ERROR(error);

	// get the security context archive
	BMessage securityContextArchive;
	error = settings.FindMessage("security context",
		&securityContextArchive);
	if (error != B_OK)
		RETURN_ERROR(error);

	// create a security context
	SecurityContext* securityContext
		= new(std::nothrow) SecurityContext(&securityContextArchive);
	if (!securityContext)
		RETURN_ERROR(B_NO_MEMORY);
	ObjectDeleter<SecurityContext> securityContextDeleter(securityContext);
	error = securityContext->InitCheck();
	if (error != B_OK) {
		delete securityContext;
		RETURN_ERROR(error);
	}

	// set it
	delete fSecurityContext;
	fSecurityContext = securityContext;
	securityContextDeleter.Detach();

	return B_OK;
}
开发者ID:luciang,项目名称:haiku,代码行数:55,代码来源:NetFSServer.cpp


注:本文中的BEntry::Exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。