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


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

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


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

示例1: BPath

BPath*
find_existing_subpath(BPath *fullpath) {
  if(exists(fullpath)) return new BPath(*fullpath);
  BPath *current;
  BPath previous = BPath(*fullpath);
  previous.GetParent(current);
  while(!(exists(current))) {
    current->GetParent(&previous);
    BPath *tmp = &previous;
    previous = *current;
    current = tmp;
  }
  return new BPath(previous);
}
开发者ID:astrieanna,项目名称:haiku-dropbox-client,代码行数:14,代码来源:HaikuDropbox.cpp

示例2: SetFile

status_t ArpConfigureFile::SetFile(const char* name)
{
    ArpD(cdb << ADH << "ArpConfigureFile: setting file from path = "
         << name << endl);

    BEntry entry(&mFile);
    if( entry.InitCheck() != B_OK ) return entry.InitCheck();

    BPath path;
    status_t err = entry.GetPath(&path);
    if( err != B_OK ) return err;

    ArpD(cdb << ADH << "ArpConfigureFile: orig path = "
         << path << endl);

    err = path.InitCheck();
    if( err == B_OK ) err = path.GetParent(&path);
    if( err == B_OK ) err = path.Append(name);
    ArpD(cdb << ADH << "ArpConfigureFile: renamed path = "
         << path.Path() << endl);

    if( err != B_OK ) return err;

    entry.SetTo(path.Path());
    err = entry.InitCheck();
    if( err != B_OK ) return err;

    entry_ref ref;
    err = entry.GetRef(&ref);
    if( err != B_OK ) return err;

    return SetFile(ref);
}
开发者ID:dtbinh,项目名称:Sequitur,代码行数:33,代码来源:ArpConfigureFile.cpp

示例3: LegacyBootMenu

BootManagerController::BootManagerController()
	:
	fBootDrive(NULL),
	fBootMenu(NULL)
{
	// set defaults
	fSettings.AddBool("install", true);
	fSettings.AddInt32("defaultPartition", 0);
	fSettings.AddInt32("timeout", -1);

	BPath path;
	if (find_directory(B_USER_SETTINGS_DIRECTORY, &path, true) == B_OK) {
		path.Append("bootman/MBR");
		fSettings.AddString("file", path.Path());
		// create directory
		BPath parent;
		if (path.GetParent(&parent) == B_OK) {
			BDirectory directory;
			directory.CreateDirectory(parent.Path(), NULL);
		}
	} else {
		fSettings.AddString("file", "");
	}

	// That's the only boot menu we support at the moment.
	fBootMenus.AddItem(new LegacyBootMenu());
}
开发者ID:DonCN,项目名称:haiku,代码行数:27,代码来源:BootManagerController.cpp

示例4: appRef

// ---------------------------------------------------------------
// GetBitmapFile
//
// Returns a BBitmap object for the bitmap file named kName.
// The user has to delete this object.
//
// Preconditions:
//
// Parameters: kName, the name of the bitmap file
//             roster, BTranslatorRoster used to do the translation
//
// Postconditions:
//
// Returns: NULL, if the file couldn't be opened or couldn't
//                be translated to a BBitmap
//          BBitmap * to the bitmap file named kName
// ---------------------------------------------------------------
BBitmap *
BTranslationUtils::GetBitmapFile(const char *kName, BTranslatorRoster *roster)
{
	if (!be_app || !kName || kName[0] == '\0')
		return NULL;
		
	BPath path;
	if (kName[0] != '/') {
		// If kName is a relative path, use the path of the application's
		// executable as the base for the relative path
		app_info info;
		if (be_app->GetAppInfo(&info) != B_OK)
			return NULL;
		BEntry appRef(&info.ref);
		if (path.SetTo(&appRef) != B_OK)
			return NULL;
		if (path.GetParent(&path) != B_OK)
			return NULL;
		if (path.Append(kName) != B_OK)
			return NULL;

	} else if (path.SetTo(kName) != B_OK)
		return NULL;
		
	BFile bitmapFile(path.Path(), B_READ_ONLY);
	if (bitmapFile.InitCheck() != B_OK)
		return NULL;

	return GetBitmap(&bitmapFile, roster);
		// Translate the data in memio using the BTranslatorRoster roster
}
开发者ID:mmanley,项目名称:Antares,代码行数:48,代码来源:TranslationUtils.cpp

示例5: entry

void
BeNetWindow::LaunchHelp()
{
	Output::Instance()->UI("BeNetWindow::LaunchHelp\n");
//	entry_ref ref;
	
// OliverESP: I though do something like this
// I saw code from SampleStudio and they make the same
// it doesn´t look pretty. All this just to know your current path

		BPath path;
		
		app_info ai;
		be_app->GetAppInfo(&ai);	
		BEntry entry(&ai.ref);
		
		entry.GetPath(&path);
		path.GetParent(&path);
		path.Append("help/gettingstarted.htm");
		
		char *help = new char[strlen(path.Path())+1];
		sprintf(help, path.Path());
		be_roster->Launch("text/html",1, &help);
		delete help;	

//	if (get_ref_for_path("help/help.htm", &ref) == B_OK)
//		be_roster->Launch(&ref);

}
开发者ID:BackupTheBerlios,项目名称:dengon-svn,代码行数:29,代码来源:BeNetWindow.cpp

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

示例7: entry

char *__PHYSFS_platformCalcBaseDir(const char *argv0)
{
    image_info info;
    int32 cookie = 0;

    while (get_next_image_info(0, &cookie, &info) == B_OK)
    {
        if (info.type == B_APP_IMAGE)
            break;
    } /* while */

    BEntry entry(info.name, true);
    BPath path;
    status_t rc = entry.GetPath(&path);  /* (path) now has binary's path. */
    assert(rc == B_OK);
    rc = path.GetParent(&path); /* chop filename, keep directory. */
    assert(rc == B_OK);
    const char *str = path.Path();
    assert(str != NULL);
    const size_t len = strlen(str);
    char *retval = (char *) allocator.Malloc(len + 2);
    BAIL_IF(!retval, PHYSFS_ERR_OUT_OF_MEMORY, NULL);
    strcpy(retval, str);
    retval[len] = '/';
    retval[len+1] = '\0';
    return retval;
} /* __PHYSFS_platformCalcBaseDir */
开发者ID:Alexander-r,项目名称:physfs,代码行数:27,代码来源:physfs_platform_haiku.cpp

示例8: AddLanguageMenu

void PrefGeneral::AddLanguageMenu()
{
	while (langmenu->ItemAt(0))
		langmenu->RemoveItem(langmenu->ItemAt(0));

	app_info ai;
	be_app->GetAppInfo(&ai);
	BEntry entry(&ai.ref);
	BPath path;
	entry.GetPath(&path);
	path.GetParent(&path);
	path.Append("Languages");
	BDirectory directory(path.Path());
	char name[B_FILE_NAME_LENGTH];

	while (directory.GetNextEntry(&entry, false) == B_OK){
		if(entry.IsFile()){
			entry.GetPath(&path);
			entry.GetName(name);
			BMessage *m = new BMessage(CHANGE_LANGUAGE);
			m->AddString("language",name);
			BMenuItem *menuitem = new BMenuItem(name, m, 0, 0);
			menuitem->SetTarget(this);
			langmenu->AddItem(menuitem);
			if(!strcmp(name,Language.Name())){
				menuitem->SetMarked(true);
			}
		}
	}
}
开发者ID:HaikuArchives,项目名称:BeAE,代码行数:30,代码来源:PrefGeneral.cpp

示例9:

bool
TRoster::_IsSystemApp(RosterAppInfo* info) const
{
	BPath path;
	if (path.SetTo(&info->ref) != B_OK || path.GetParent(&path) != B_OK)
		return false;

	return !strcmp(path.Path(), fSystemAppPath.Path())
		|| !strcmp(path.Path(), fSystemServerPath.Path());
}
开发者ID:looncraz,项目名称:haiku,代码行数:10,代码来源:TRoster.cpp

示例10: BPath

BPath
DjVuApp::Path(const char *dir)
{
	app_info inf;
   	be_app->GetAppInfo(&inf);
   	BPath bpath = BPath(&(inf.ref));
   	BPath par; 
   	bpath.GetParent(&par);
   	par.Append(dir);
	return(par);
}
开发者ID:threedeyes,项目名称:DjVuViewer,代码行数:11,代码来源:MainApp.cpp

示例11: entry

status_t
BIconButton::SetIcon(const char* pathToBitmap)
{
	if (pathToBitmap == NULL)
		return B_BAD_VALUE;

	status_t status = B_BAD_VALUE;
	BBitmap* fileBitmap = NULL;
	// try to load bitmap from either relative or absolute path
	BEntry entry(pathToBitmap, true);
	if (!entry.Exists()) {
		app_info info;
		status = be_app->GetAppInfo(&info);
		if (status == B_OK) {
			BEntry app_entry(&info.ref, true);
			BPath path;
			app_entry.GetPath(&path);
			status = path.InitCheck();
			if (status == B_OK) {
				status = path.GetParent(&path);
				if (status == B_OK) {
					status = path.Append(pathToBitmap, true);
					if (status == B_OK)
						fileBitmap = BTranslationUtils::GetBitmap(path.Path());
					else {
						printf("BIconButton::SetIcon() - path.Append() failed: "
							"%s\n", strerror(status));
					}
				} else {
					printf("BIconButton::SetIcon() - path.GetParent() failed: "
						"%s\n", strerror(status));
				}
			} else {
				printf("BIconButton::SetIcon() - path.InitCheck() failed: "
					"%s\n", strerror(status));
			}
		} else {
			printf("BIconButton::SetIcon() - be_app->GetAppInfo() failed: "
				"%s\n", strerror(status));
		}
	} else
		fileBitmap = BTranslationUtils::GetBitmap(pathToBitmap);
	if (fileBitmap) {
		status = _MakeBitmaps(fileBitmap);
		delete fileBitmap;
	} else
		status = B_ERROR;
	return status;
}
开发者ID:Barrett17,项目名称:Faber,代码行数:49,代码来源:IconButton.cpp

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

示例13: BPath

bool
BTheme::SetDirectory(const char *path)
{
 if(path[0]=='.' && strlen(path)>2)
 {
   app_info inf;
   be_app->GetAppInfo(&inf);
   BPath bpath = BPath(&(inf.ref));
   BPath par; bpath.GetParent(&par);
   par.Append(path+2);
   ThemesFolder.SetTo(par.Path());
  }
  else
   ThemesFolder.SetTo(path);
  return true;
}
开发者ID:threedeyes,项目名称:DjVuViewer,代码行数:16,代码来源:Theme.cpp

示例14: strlen

static int32 expand_dir(char* buffer, const char* dir)
{
	int32 size=0;
	while( dir && *dir ) {
		if( *dir == '%' ) {
			dir++;
			switch( *dir ) {
				case '%':
					break;
				case 'A': {
					BPath path;
					if( get_app_path(&path) == B_NO_ERROR ) {
						if( path.GetParent(&path) == B_NO_ERROR ) {
							const char* dir = path.Path();
							if( dir ) {
								ArpD(cdb << ADH << "App dir = " << dir << endl);
								int len = strlen(dir);
								size += len;
								if( buffer ) {
									memcpy(buffer,dir,len);
									buffer += len;
								}
							}
						}
					}
					dir++;
				} break;
				case 0:
					if( buffer ) *buffer = 0;
					return size+1;
				default:
					dir++;
					break;
			}
		}
		if( buffer ) *(buffer++) = *dir;
		dir++;
		size++;
	}
	if( buffer ) *buffer = 0;
	return size+1;
}
开发者ID:HaikuArchives,项目名称:ArpCommon,代码行数:42,代码来源:ArpMultiDir.cpp

示例15: entry

char *__PHYSFS_platformCalcBaseDir(const char *argv0)
{
    /* in case there isn't a BApplication yet, we'll construct a roster. */
    BRoster roster;
    app_info info;
    status_t rc = roster.GetRunningAppInfo(getTeamID(), &info);
    BAIL_IF_MACRO(rc < B_OK, strerror(rc), NULL);
    BEntry entry(&(info.ref), true);
    BPath path;
    rc = entry.GetPath(&path);  /* (path) now has binary's path. */
    assert(rc == B_OK);
    rc = path.GetParent(&path); /* chop filename, keep directory. */
    assert(rc == B_OK);
    const char *str = path.Path();
    assert(str != NULL);
    char *retval = (char *) allocator.Malloc(strlen(str) + 1);
    BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
    strcpy(retval, str);
    return(retval);
} /* __PHYSFS_platformCalcBaseDir */
开发者ID:BackupTheBerlios,项目名称:netpanzer-svn,代码行数:20,代码来源:beos.cpp


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