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


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

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


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

示例1: 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

示例2: GetAppInfo

void
ServerApp::_LaunchAddOnServer()
{
    // Try to launch media_addon_server by mime signature.
    // If it fails (for example on the Live CD, where the executable
    // hasn't yet been mimesetted), try from this application's
    // directory
    status_t err = be_roster->Launch(B_MEDIA_ADDON_SERVER_SIGNATURE);
    if (err == B_OK)
        return;

    app_info info;
    BEntry entry;
    BDirectory dir;
    entry_ref ref;

    err = GetAppInfo(&info);
    err |= entry.SetTo(&info.ref);
    err |= entry.GetParent(&entry);
    err |= dir.SetTo(&entry);
    err |= entry.SetTo(&dir, "media_addon_server");
    err |= entry.GetRef(&ref);

    if (err == B_OK)
        be_roster->Launch(&ref);
    if (err == B_OK)
        return;

    (new BAlert("media_server", "Launching media_addon_server failed.\n\n"
                "media_server will terminate", "OK"))->Go();
    fprintf(stderr, "Launching media_addon_server (%s) failed: %s\n",
            B_MEDIA_ADDON_SERVER_SIGNATURE, strerror(err));
    exit(1);
}
开发者ID:nielx,项目名称:haiku-serviceskit,代码行数:34,代码来源:media_server.cpp

示例3: fDocIO

CDoc::CDoc(const char* mimetype, BLooper *target, const entry_ref *doc)
	: fDocIO(NULL)
	, fSavePanel(NULL)
	, fMimeType(mimetype ? mimetype : "")
	, fDirty(false)
	, fReadOnly(false)
	, fEncoding(B_UNICODE_UTF8)
	, fLineEndType(kle_LF)
{
	fDocIO = new CLocalDocIO(this, doc, target);
	FailNil(fDocIO);
	if (doc)
	{
		BEntry e;
		FailOSErr(e.SetTo(doc, true));
		FailOSErr(e.GetParent(&gCWD));

		BNode node;
		FailOSErr(node.SetTo(doc));

		struct stat st;
		FailOSErr(node.GetStat(&st));

		fReadOnly = !((gUid == st.st_uid && (S_IWUSR & st.st_mode))
						||	(gGid == st.st_gid && (S_IWGRP & st.st_mode))
						||	(S_IWOTH & st.st_mode));

		char s[NAME_MAX];
		if (BNodeInfo(&node).GetType(s) == B_OK)
			fMimeType = s;
	}
	sfDocList.push_back(this);
}
开发者ID:diversys,项目名称:pe,代码行数:33,代码来源:CDoc.cpp

示例4: 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

示例5: Directory

status_t
DirectoryView::OpenDirectory(const Entry* dir)
{
	if (! dir->IsDirectory()) {
		return B_ERROR;
	}

	// stop node watcher
	stop_watching(this);

	// clear entry data and listview
	mListView->DeleteAllItems();
 	entryList_.DeleteAllItems();
	if (entry_) {
		delete entry_;
		entry_ = NULL;
	}
	if (parent_) {
		delete parent_;
		parent_ = NULL;
	}
	UpdateStatus();

	// set current directory
	entry_ = new Directory(*(Directory*)dir);

	// get parent directory
	BEntry bentry;
	if (entry_->GetBEntry(&bentry) == B_OK) {
		BEntry parent;
		if (bentry.GetParent(&parent) == B_OK) {
			parent_ = new Directory(parent);
		}
	}

	// get directory entry
	ListVisitor* lv1 = new ListVisitor(*entry_, &entryList_);
	lv1->Go();
	delete lv1;

	// show directory entry
	if (parent_ != NULL) {
		mListView->AddItem(new EntryListItem(parent_, EntryListItem::ENTRY_IS_PARENT));
	}
	mListView->AddEntryList((BList*) &entryList_);
	mListView->DoSort();
	if (mListView->CountItems() > 0)
		mListView->Select(0);
	UpdateStatus();

	// start node watcher
	if (bentry.InitCheck() == B_OK) {
		node_ref nref;
		bentry.GetNodeRef(&nref);
		watch_node(&nref, B_WATCH_ALL, this);
	}

	return B_OK;
}
开发者ID:TheNavigat,项目名称:BAfx,代码行数:59,代码来源:DirectoryView.cpp

示例6:

void 
BNavigator::GoUp(bool option)
{
	BEntry entry;
	if (entry.SetTo(fPath.Path()) == B_OK) {
		BEntry parentEntry;
		if (entry.GetParent(&parentEntry) == B_OK && !FSIsDeskDir(&parentEntry))
			SendNavigationMessage(kActionUp, &parentEntry, option);
	}
}
开发者ID:HaikuArchives,项目名称:OpenTracker,代码行数:10,代码来源:Navigator.cpp

示例7: directory

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) {
			BAlert* alert = new BAlert("Open Target Folder",
				"Cannot open target folder. Maybe this link is broken?",
				"OK", NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
			alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
			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) {
		BAlert* alert = 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");
		alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
		alert->Go(NULL);
	}
}
开发者ID:Barrett17,项目名称:haiku-contacts-kit-old,代码行数:53,代码来源:opentargetfolder.cpp

示例8: BPath

void 
BNavigator::UpdateLocation(const Model *newmodel, int32 action)
{
	if (newmodel)
		newmodel->GetPath(&fPath);


	// Modify history according to commands
	switch (action) {
		case kActionBackward:
			fForwHistory.AddItem(fBackHistory.RemoveItemAt(fBackHistory.CountItems()-1));
			break;
		case kActionForward:
			fBackHistory.AddItem(fForwHistory.RemoveItemAt(fForwHistory.CountItems()-1));
			break;
		case kActionUpdatePath:
			break;
		default:
			fForwHistory.MakeEmpty();
			fBackHistory.AddItem(new BPath(fPath));

			for (;fBackHistory.CountItems()>kMaxHistory;)
				fBackHistory.RemoveItem(fBackHistory.FirstItem(), true);
			break;			
	}

	// Enable Up button when there is any parent
	BEntry entry;
	if (entry.SetTo(fPath.Path()) == B_OK) {
		BEntry parentEntry;
		fUp->SetEnabled(entry.GetParent(&parentEntry) == B_OK && !FSIsDeskDir(&parentEntry));
	}

	// Enable history buttons if history contains something
	fForw->SetEnabled(fForwHistory.CountItems() > 0);
	fBack->SetEnabled(fBackHistory.CountItems() > 1);

	// Avoid loss of selection and cursor position
	if (action != kActionLocation)
		fLocation->SetText(fPath.Path());
}
开发者ID:HaikuArchives,项目名称:OpenTracker,代码行数:41,代码来源:Navigator.cpp

示例9: BEntry

floppyFilePanel::floppyFilePanel (int32_t drive):
	BFilePanel (B_OPEN_PANEL, NULL, NULL, 0, false, NULL, 0, true, true)
{
    char title[80];
    BEntry dir      = BEntry (currprefs.df[drive]);
    BMessage   msg  = BMessage (MSG_FLOPPY_PANEL_DRIVE0 + drive);

    dir.GetParent (&dir);
    sprintf (title, "UAE: Select image to insert in drive DF%d:", drive);

    done_sem = create_sem (0, NULL);

    be_app->Lock ();
    be_app->AddHandler (this);
    be_app->Unlock ();

    this->SetTarget (BMessenger (this));
    this->SetMessage (&msg);
    this->SetPanelDirectory (&dir);
    this->Window ()->SetTitle (title);
}
开发者ID:Yamakuzure,项目名称:PUAE,代码行数:21,代码来源:gui.cpp

示例10: path

status_t
PathHandler::_AddDirectory(BEntry& entry, bool notify)
{
	WatchedDirectory directory;
	status_t status = entry.GetNodeRef(&directory.node);
	if (status != B_OK)
		return status;

#ifdef TRACE_PATH_MONITOR
{
	BPath path(&entry);
	TRACE("  ADD DIRECTORY %s, %ld:%Ld\n",
		path.Path(), directory.node.device, directory.node.node);
}
#endif

	// check if we are already know this directory

	// TODO: It should be possible to ommit this check if we know it
	// can't be the case (for example when adding subfolders recursively,
	// although in that case, the API user may still have added this folder
	// independently, so for now, it should be the safest to perform this
	// check in all cases.)
	if (_HasDirectory(directory.node))
		return B_OK;

	directory.contained = _IsContained(entry);

	uint32 flags;
	if (directory.contained)
		flags = (fFlags & WATCH_NODE_FLAG_MASK) | B_WATCH_DIRECTORY;
	else
		flags = B_WATCH_DIRECTORY;

	status = watch_node(&directory.node, flags, this);
	if (status != B_OK)
		return status;

	fDirectories.insert(directory);

	if (_WatchRecursively()) {
		BDirectory dir(&directory.node);
		while (dir.GetNextEntry(&entry) == B_OK) {
			if (entry.IsDirectory()) {
				// and here is the recursion:
				if (_AddDirectory(entry, notify) != B_OK)
					break;
			} else if (!_WatchFoldersOnly()) {
				if (_AddFile(entry, notify) != B_OK)
					break;
			}
		}
	}

#if 0
	BEntry parent;
	if (entry.GetParent(&parent) == B_OK
		&& !_IsContained(parent)) {
		// TODO: remove parent from watched directories
	}
#endif
	return B_OK;
}
开发者ID:mmanley,项目名称:Antares,代码行数:63,代码来源:PathMonitor.cpp

示例11: BWindow

HelloWindow::HelloWindow(BRect theframe)
				: BWindow(theframe, "DynaMate",  B_TITLED_WINDOW, B_NOT_RESIZABLE)
{
/// /// /// /// SOUND /// /// /// /// LÄGG TILL FELKOLLAR !!
	error=0;
	snd = new SoundStuff;

	app_info ai;	
	if (be_app->GetAppInfo(&ai)){ error = B_ERROR; fputs("DynaMate: Error getting AppInfo.\n",stderr); return;}

	entry_ref mref, sref, eref;
	BEntry *ment, *sent, *eent;
	
	BDirectory dir;
	BEntry *exeEnt;
	
	exeEnt = new BEntry(&(ai.ref));
	if (exeEnt->InitCheck())	{ error = B_ERROR; fputs("DynaMate: Error converting ref to Entry.\n",stderr); return;}
	if (exeEnt->GetParent(&dir)){ error = B_ERROR; fputs("DynaMate: Error getting parent.\n",stderr); return;}
	
	ment = new BEntry(&dir, "sfx/move");
	if (ment->InitCheck())		{ error = B_ERROR; fputs("DynaMate: Problems with file 'sfx/move'.\n",stderr); return;}

	sent = new BEntry(&dir, "sfx/stop");
	if (sent->InitCheck())		{ error = B_ERROR; fputs("DynaMate: Problems with file 'sfx/stop'.\n",stderr); return;}

	eent = new BEntry(&dir, "sfx/explosion");
	if (eent->InitCheck())		{ error = B_ERROR; fputs("DynaMate: Problems with file 'sfx/explosion'.\n",stderr); return;}

	if (ment->GetRef(&mref))	{ error = B_ERROR; fputs("DynaMate: Error converting ref to Entry.(mref)\n",stderr); return;}
	if (sent->GetRef(&sref))	{ error = B_ERROR; fputs("DynaMate: Error converting ref to Entry.(sref)\n",stderr); return;}
	if (eent->GetRef(&eref))	{ error = B_ERROR; fputs("DynaMate: Error converting ref to Entry.(eref)\n",stderr); return;}

	delete ment;
	delete sent;
	delete eent;
	delete exeEnt;

	snd->moveblip = new BSound(&mref,true);
	snd->stopblip = new BSound(&sref,true);
	snd->explblip = new BSound(&eref,true);

	if (snd->moveblip->InitCheck()) { error = B_ERROR; fputs("DynaMate: Problems with file 'sfx/move'.\n",stderr); return;}
	if (snd->stopblip->InitCheck()) { error = B_ERROR; fputs("DynaMate: Problems with file 'sfx/stop'.\n",stderr); return;}
	if (snd->explblip->InitCheck()) { error = B_ERROR; fputs("DynaMate: Problems with file 'sfx/explosion'.\n",stderr); return;}

/// /// /// /// /// /// /// /// ///

	frame=theframe;
	totalmoves=0;
	stonesleft=65535;
	SIZE=16;
	file = NULL;		
// reservera banan
	level=(uint8 *)malloc(256+1);		// 256==en piece 1==rekordet
	
// Starta en view	
	frame.OffsetTo(B_ORIGIN);

	gameView = NULL;
	titleView = NULL;
	LaunchTitle();
}
开发者ID:HaikuArchives,项目名称:Dynamate,代码行数:63,代码来源:DmWindow.cpp

示例12: main

int main(int argc, char *argv[])
{
	yyin = stdin;

	int i = getoptions(argc, argv);

	char buf[PATH_MAX];
	if (out[0] == '/')
		strcpy(buf, out);
	else
	{
		getcwd(buf, PATH_MAX);
		strcat(buf, "/");
		strcat(buf, out);
	}

	BEntry e;
	if (e.SetTo(out)) error("entry set to %s", out);

	BDirectory d;
	if (e.GetParent(&d)) error("get parent of %s", out);
	if ((gTruncate || gSaveAsHeader) && e.Exists() && e.Remove())
		error("removing %s", out);

	BFile f;
	BResources res;

	if (!gDump)
	{
		if (gTruncate || !e.Exists())
		{
			if (d.CreateFile(buf, &f)) error("creating %s", buf);
			gTruncate = true;
		}
		else
			if (f.SetTo(buf, B_READ_WRITE)) error("opening %s", buf);

		if (gSaveAsHeader)
		{
			gHeader = fopen(buf, "w");
			if (!gHeader) error("Error creating %s", buf);
		}
		else if (res.SetTo(&f, gTruncate) != B_NO_ERROR)
			error("opening resource file %s", buf);
	}

	resFile = &res;

	if (i == argc)
		Work(NULL);
	else
	{
		while (i < argc)
			Work(in = argv[i++]);
	}

	if (verbose)
		puts("done");

	if (gHeader)
		fclose(gHeader);
	else
		f.Sync();

	return 0;
} /* main */
开发者ID:HaikuArchives,项目名称:Pe,代码行数:66,代码来源:rez.cpp

示例13: path

void
Snapshot::ProcessRefs	(BMessage * msg)
{
//	init
	BString command			=	"/bin/zip -ry ";
	BString snapshot_name	=	m_snapshot_dir_path.Path();
	BString file_list;
	
	status_t	status	=	B_OK;
	entry_ref	ref;
	entry_ref	last_ref;
	bool		same_folder	=	true;
	
/*
	entry_ref	dir_ref;

	status	=	msg->FindRef("dir_ref", &dir_ref);
	if (status == B_OK)
	{
		BPath path (& dir_ref);		// when used as Tracker addon
		chdir(path.Path());			// telling zip where to work
	}							
*/	
	type_code	ref_type	=	B_REF_TYPE;
	int32		ref_count	=	0;
	
	status	=	msg->GetInfo("refs", & ref_type, & ref_count);
	if (status != B_OK)
		return;


	if (ref_count < 1)
		return;

	for (int index = 0;	index < ref_count ;	index++)
	{
		msg->FindRef("refs", index, & ref);
		
		if (index > 0)
		{
			if (last_ref.directory != ref.directory)
			{
				same_folder	=	false;
				break;
			}
		}
		
		last_ref =	ref;
	}	

	// change dir to avoid full paths in zip archive
	if (same_folder)
	{
		BEntry	entry	(& ref);
		entry.GetParent(& entry);
		BPath	path	(& entry);
		chdir (path.Path());
	}

	// snapshost_name
	if (ref_count == 1)
	{
		snapshot_name	+=	"/";
		snapshot_name	+=	ref.name;
		snapshot_name	+=	".zip";			
	}
	
	if (ref_count > 1)
		snapshot_name	+=	"/multiple_files.zip";	

	// create timestamp
	time_t	current_time	=	time(NULL);
	char * timestamp = new char [100];
	strftime(timestamp, 99, "%Y.%m.%d_%H:%M:%S", localtime(& current_time));

	snapshot_name	+=	" (";
	snapshot_name	+=	timestamp;	
	snapshot_name	+=	")";

	MakeShellSafe(& snapshot_name);

	// files to zip
	for (int index = 0;	index < ref_count ;	index++)
	{
		msg->FindRef("refs", index, & ref);
		// BPath path (& ref);
	
		if (same_folder)				// just the file name
		{
			BString file = ref.name;
			MakeShellSafe (& file);
		
			file_list += " ";
			file_list += file;
		}
		else							// full path
		{
			BString file;
			BPath	path	(& ref);
			file	=	path.Path();
//.........这里部分代码省略.........
开发者ID:HaikuArchives,项目名称:Snapshot,代码行数:101,代码来源:Snapshot.cpp


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