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


C++ BEntry类代码示例

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


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

示例1: fwrite

status_t 
PoorManWindow::SaveConsole(BMessage* message, bool selection)
{
	entry_ref	ref;
	const char* name;
	BPath		path;
	BEntry		entry;
	status_t	err = B_OK;
	FILE*		f;
	
	err = message->FindRef("directory", &ref);
	if (err != B_OK)
		return err;
	
	err = message->FindString("name", &name);
	if (err != B_OK)
		return err;
	
	err = entry.SetTo(&ref);
	if (err != B_OK)
		return err;
	
	entry.GetPath(&path);
	path.Append(name);
	
	if (!(f = fopen(path.Path(), "w")))
		return B_ERROR;
	
	if (!selection) {
		// write the data to the file
		err = fwrite(fLoggingView->Text(), 1, fLoggingView->TextLength(), f);
	} else {
		// find the selected text and write it to a file
		int32 start = 0, end = 0;
		fLoggingView->GetSelection(&start, &end);
		
		BString buffer;
		char * buffData = buffer.LockBuffer(end - start + 1);
		// copy the selected text from the TextView to the buffer	
		fLoggingView->GetText(start, end - start, buffData);
		buffer.UnlockBuffer(end - start + 1);
		
		err = fwrite(buffer.String(), 1, end - start + 1, f);
	}
	
	fclose(f);
	
	return err;
}
开发者ID:Barrett17,项目名称:haiku-contacts-kit-old,代码行数:49,代码来源:PoorManWindow.cpp

示例2: process_refs

extern "C" void
process_refs(entry_ref directoryRef, BMessage *msg, void *)
{
	BDirectory directory(&directoryRef);
	if (directory.InitCheck() != B_OK)
		return;

	int32 errors = 0;
	entry_ref ref;
	int32 index;
	for (index = 0; msg->FindRef("refs", index, &ref) == B_OK; index ++) {
		BSymLink link(&ref);
		if (link.InitCheck() != B_OK || !link.IsSymLink()) {
			errors++;
			continue;
		}

		BEntry targetEntry;
		BPath path;
		if (link.MakeLinkedPath(&directory, &path) < B_OK
			|| targetEntry.SetTo(path.Path()) != B_OK
			|| targetEntry.GetParent(&targetEntry) != B_OK) {
			(new BAlert("Open Target Folder",
				"Cannot open target folder. Maybe this link is broken?",
				"OK", NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go(NULL);
			continue;
		}

		// create Tracker message...
		entry_ref target;
		targetEntry.GetRef(&target);

		BMessage message(B_REFS_RECEIVED);
		message.AddRef("refs", &target);

		// ...and send it
		BMessenger messenger("application/x-vnd.Be-TRAK");
		messenger.SendMessage(&message);

		// TODO: select entry via scripting?
	}

	if (errors) {
		(new BAlert("Open Target Folder",
			"This add-on can only be used on symbolic links.\n"
			"It opens the folder of the link target in Tracker.",
			"OK"))->Go(NULL);
	}
}
开发者ID:mariuz,项目名称:haiku,代码行数:49,代码来源:opentargetfolder.cpp

示例3: addonName

status_t
ModuleManager::_GetAddOn(const char *name, ModuleAddOn **_addon)
{
	// search list first
	for (int32 i = 0; ModuleAddOn *addon = fAddOns.ItemAt(i); i++) {
		BString addonName(addon->Name());
		addonName << "/";
		if (!strcmp(name, addon->Name())
			|| !strncmp(addonName.String(), name, addonName.Length())) {
			addon->Get();
			*_addon = addon;
			return B_OK;
		}
	}
	// not in list yet, load from disk
	// iterate through module dirs
	for (int32 i = 0; gModuleDirs[i]; i++) {
		BPath path;
		if (path.SetTo(gModuleDirs[i]) == B_OK
			&& path.SetTo(path.Path(), name) == B_OK) {
			BEntry entry;
			for (;;) {
				if (entry.SetTo(path.Path()) == B_OK && entry.Exists()) {
					// found an entry: if it is a file, try to load it
					if (entry.IsFile()) {
						ModuleAddOn *addon = new ModuleAddOn;
						if (addon->Load(path.Path(), gModuleDirs[i]) == B_OK) {
							status_t status = addon->Get();
							if (status < B_OK) {
								delete addon;
								return status;
							}

							fAddOns.AddItem(addon);
							*_addon = addon;
							return B_OK;
						}
						delete addon;
					}
					break;
				}
				// chop off last path component
				if (path.GetParent(&path) != B_OK)
					break;
			}
		}
	}
	return B_ENTRY_NOT_FOUND;
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:49,代码来源:module.cpp

示例4:

status_t
DecorThemesAddon::RunPreferencesPanel()
{
	status_t err;
	entry_ref ref;
	BEntry ent;
	err = ent.SetTo("/boot/beos/references/Appearance");
	if (!err) {
		err = ent.GetRef(&ref);
		if (!err) {
			err = be_roster->Launch(&ref);
		}
	}
	return err;
}
开发者ID:mmanley,项目名称:Antares,代码行数:15,代码来源:AntaresWindowDecorAddon.cpp

示例5: scan_directory

// Scans a directory and adds the entries it founds as strings to the
// given list
static int32
scan_directory(const char *directory, BList *list)
{
	BEntry entry;
	BDirectory dir(SERIAL_DIR);
	char buf[B_OS_NAME_LENGTH];
	
	ASSERT(list != NULL);
	while (dir.GetNextEntry(&entry) == B_OK) {
		entry.GetName(buf);
		list->AddItem(strdup(buf));
	};
	
	return list->CountItems();
}
开发者ID:mariuz,项目名称:haiku,代码行数:17,代码来源:SerialPort.cpp

示例6: SetTo

/*! \brief Reinitializes the object to the entry referred to by the specified
	path rooted in the specified directory.
	\param dir the BDirectory, relative to which the entry's path name is
		   given
	\param path the entry's path name relative to \a dir
	\return
	- \c B_OK: Everything went fine.
	- \c B_BAD_VALUE: \c NULL \a dir or \a path.
	- \c B_ENTRY_NOT_FOUND: The entry could not be found.
	- \c B_BUSY: The entry is locked.
	\todo Implemented using SetTo(BEntry*). Check, if necessary to reimplement!
*/
status_t
BNode::SetTo(const BDirectory *dir, const char *path)
{
	Unset();
	status_t error = (dir && path ? B_OK : B_BAD_VALUE);
	if (error == B_OK && BPrivate::Storage::is_absolute_path(path))
		error = B_BAD_VALUE;
	BEntry entry;
	if (error == B_OK)
		error = entry.SetTo(dir, path);
	if (error == B_OK)
		error = SetTo(&entry);
	fCStatus = error;
	return error;
}
开发者ID:Ithamar,项目名称:cosmoe,代码行数:27,代码来源:Node.cpp

示例7: BTranslatorItem

void
InspectorApp::AddToTranslatorsList(const char *folder, int32 group)
{
	BDirectory dir;
	if (dir.SetTo(folder) == B_OK) {
	
		BEntry ent;
		while (dir.GetNextEntry(&ent) == B_OK) {
			BPath path;
			if (ent.GetPath(&path) == B_OK)
				flstTranslators.AddItem(
					new BTranslatorItem(path.Leaf(), path.Path(), group));
		}	
	}
}
开发者ID:mariuz,项目名称:haiku,代码行数:15,代码来源:InspectorApp.cpp

示例8: ContentName

/*!	\brief Returns the mount point for the partition.

	If the partition is mounted this is the actual mount point. If it is not
	mounted, but contains a file system, derived from the partition name
	the name for a not yet existing directory in the root directory is
	constructed and the path to it returned.

	For partitions not containing a file system the method returns an error.

	\param mountPoint Pointer to the path to be set to refer the mount point
		   (respectively potential mount point) of the partition.
	\return \c B_OK, if everything went fine, an error code otherwise.
*/
status_t
BPartition::GetMountPoint(BPath* mountPoint) const
{
	if (!mountPoint || !ContainsFileSystem())
		return B_BAD_VALUE;

	// if the partition is mounted, return the actual mount point
	BVolume volume;
	if (GetVolume(&volume) == B_OK) {
		BDirectory dir;
		status_t error = volume.GetRootDirectory(&dir);
		if (error == B_OK)
			error = mountPoint->SetTo(&dir, NULL);
		return error;
	}

	// partition not mounted
	// get the volume name
	const char* volumeName = ContentName();
	if (!volumeName || strlen(volumeName) == 0)
		volumeName = Name();
	if (!volumeName || strlen(volumeName) == 0)
		volumeName = "unnamed volume";

	// construct a path name from the volume name
	// replace '/'s and prepend a '/'
	BString mountPointPath(volumeName);
	mountPointPath.ReplaceAll('/', '-');
	mountPointPath.Insert("/", 0);

	// make the name unique
	BString basePath(mountPointPath);
	int counter = 1;
	while (true) {
		BEntry entry;
		status_t error = entry.SetTo(mountPointPath.String());
		if (error != B_OK)
			return error;

		if (!entry.Exists())
			break;
		mountPointPath = basePath;
		mountPointPath << counter;
		counter++;
	}

	return mountPoint->SetTo(mountPointPath.String());
}
开发者ID:mmanley,项目名称:Antares,代码行数:61,代码来源:Partition.cpp

示例9: Window

void
IncludeSettingsView::AddRefsToList(BListView* list, BMessage* message, bool relative = false)
{
	//XXX - it is possible for now to select only one directory each time.
	entry_ref ref;
	BEntry entry;
	BPath path;
	BString pathString;
	status_t err;
	int32 ref_num;
	bool relpath = false;
	ref_num = 0;
	//find boolean in the message
	err =  message->FindBool("relpath", &relpath);
	if (err != B_OK) {
		DPRINT("IncludeSettingsView::AddRefsToList: boolean not found");
	}

	//add this entry to the list view
	do {
		if ( (err = message->FindRef("refs", ref_num, &ref)) != B_OK ) {
			return;
		}
		entry.SetTo(&ref, true);
		//we return if for some strange reason the entry is unavailable
		if (entry.InitCheck() != B_OK) return;
		entry.GetPath(&path);
		//XXX - if "relative" convert path
		DPRINT("IncludeSettingsView::AddRefsToList: entry name = " << path.Path());
		//convert path to relative if requested
		if (relpath) {
			//find the window we are attached to...
			DPRINT("IncludeSettingsView::AddRefsToList: add relative path");
			TargetConfig* c = ((TargetSettingsWin*) Window() )->TConfig();
			assert(c != NULL); //we *must* be attached to a window here
			c->RelPathToWorkingDir(path.Path(), &pathString);
		} else {
			DPRINT("IncludeSettingsView::AddRefsToList: add absolute path");
			pathString = path.Path();
		}
		list->AddItem(new BStringItem(pathString.String()));
		//tell the window that this view has changed
		CommunicateChanges();

		ref_num++;
	} while (1);	

}
开发者ID:HaikuArchives,项目名称:JamMin,代码行数:48,代码来源:IncludeSettingsView.cpp

示例10: tryDir

    /*
     * This function is lifted from Simple Directmedia Layer (SDL):
     *  https://www.libsdl.org/  ... this is zlib-licensed code, too.
     */
static void tryDir(const char *d, PHYSFS_StringCallback callback, void *data)
{
    BDirectory dir;
    dir.SetTo(d);
    if (dir.InitCheck() != B_NO_ERROR)
        return;

    dir.Rewind();
    BEntry entry;
    while (dir.GetNextEntry(&entry) >= 0)
    {
        BPath path;
        const char *name;
        entry_ref e;

        if (entry.GetPath(&path) != B_NO_ERROR)
            continue;

        name = path.Path();

        if (entry.GetRef(&e) != B_NO_ERROR)
            continue;

        if (entry.IsDirectory())
        {
            if (strcmp(e.name, "floppy") != 0)
                tryDir(name, callback, data);
            continue;
        } /* if */

        const int devfd = open(name, O_RDONLY);
        if (devfd < 0)
            continue;

        device_geometry g;
        const int rc = ioctl(devfd, B_GET_GEOMETRY, &g, sizeof (g));
        close(devfd);
        if (rc < 0)
            continue;

        if (g.device_type != B_CD)
            continue;

        char mntpnt[B_FILE_NAME_LENGTH];
        if (getMountPoint(name, mntpnt, sizeof (mntpnt)))
            callback(data, mntpnt);
    } /* while */
} /* tryDir */
开发者ID:Alexander-r,项目名称:physfs,代码行数:52,代码来源:physfs_platform_haiku.cpp

示例11: printf

status_t HModuleRoster::StartWatching( BPath *moduleDirectory )
{
	if( watching )
		return B_ERROR;
	printf("Watching %s\n", moduleDirectory->Path());
	BEntry		entry;
	
	if( (entry.SetTo( moduleDirectory->Path() ) == B_OK)&&
		(entry.GetNodeRef( &watchedRef ) == B_OK) )
	{
		watching = true;
		return watch_node( &watchedRef, B_WATCH_DIRECTORY, this );
	}
	else
		return B_ERROR;
}
开发者ID:HaikuArchives,项目名称:RobinHood,代码行数:16,代码来源:HModuleRoster.cpp

示例12: BEntry

/*	AddFisrtInstanceAsRefToBMsg
	method adds refs of the files and folders of the "root" folder
	of the selected files to BMessage
*/
void
FileTree::AddFisrtInstanceAsRefToBMsg(BMessage *objMsg)
{
	FileTree *tmpTree;
	BEntry *objEntry = new BEntry();
	entry_ref *file_ref = new entry_ref;

	for(int i = 0; i < Nodes->CountItems(); i++) {
		tmpTree = (FileTree*)Nodes->ItemAt(i);
		objEntry->SetTo(tmpTree->Path.String());
		objEntry->GetRef(file_ref);		
		objMsg->AddRef("refs", file_ref);
	}
	
	delete objEntry;
}
开发者ID:HaikuArchives,项目名称:Lava,代码行数:20,代码来源:FileTree.cpp

示例13: GetFolder

void InfoBox::GetFolder(BDirectory dir) {

	int32 c=dir.CountEntries();
	BEntry entry;
	
	if (c>0)
	for (int32 i=0; i<c; i++) {
		dir.GetNextEntry(&entry, true);
		if (entry.IsDirectory()) {
			folders++;
			GetFolder(BDirectory(&entry));
		}
		else
			files++;
	}
}
开发者ID:carriercomm,项目名称:Helios,代码行数:16,代码来源:InfoBox.cpp

示例14: Contains

/*!	\brief Returns whether this directory or any of its subdirectories
	at any level contain the entry referred to by the supplied path name.
	Only entries that match the node flavor specified by \a nodeFlags are
	considered.
	If the BDirectory is not properly initialized, the method returns \c false.
	A non-absolute path is considered relative to the current directory.

	\note R5's implementation always returns \c true given an absolute path or 
	an unitialized directory. This implementation is not compatible with that
	behavior. Instead it converts the path into a BEntry and passes it to the
	other version of Contains().

	\param path the entry's path name. May be relative to this directory or
		   absolute.
	\param nodeFlags Any of the following:
		   - \c B_FILE_NODE: The entry must be a file.
		   - \c B_DIRECTORY_NODE: The entry must be a directory.
		   - \c B_SYMLINK_NODE: The entry must be a symbolic link.
		   - \c B_ANY_NODE: The entry may be of any kind.
	\return
	- \c true, if the entry exists, its kind does match \nodeFlags and the
	  BDirectory is properly initialized and does contain the entry at any
	  level,
	- \c false, otherwise
*/
bool
BDirectory::Contains(const char *path, int32 nodeFlags) const
{
	// check initialization and parameters
	if (InitCheck() != B_OK)
		return false;
	if (!path)
		return true;	// mimic R5 behavior
	// turn the path into a BEntry and let the other version do the work
	BEntry entry;
	if (BPrivate::Storage::is_absolute_path(path))
		entry.SetTo(path);
	else
		entry.SetTo(this, path);
	return Contains(&entry, nodeFlags);
}
开发者ID:Ithamar,项目名称:cosmoe,代码行数:41,代码来源:Directory.cpp

示例15: if

bool
InitialIterator::GetTopEntry(BEntry& entry)
{
	// If the user selected one or more files, we must look
	// at the "refs" inside the message that was passed into
	// our add-on's process_refs(). If the user didn't select
	// any files, we will simply read all the entries from the
	// current working directory.

	entry_ref fileRef;

	if (fSelectedFiles.FindRef("refs", fCurrentRef, &fileRef) == B_OK) {
		entry.SetTo(&fileRef, fRecurseLinks);
		++fCurrentRef;
		return true;
	} else if (fCurrentRef > 0) {
		// when we get here, we have processed
		// all the refs from the message
		return false;
	} else if (fCurrentDir != NULL) {
		// examine the whole directory
		return fCurrentDir->GetNextEntry(&entry, fRecurseLinks) == B_OK;
	}

	return false;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:26,代码来源:InitialIterator.cpp


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