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


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

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


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

示例1: Load

status_t TaskFS::Load(void)
{
	status_t err = B_OK;
	BEntry *tmpEntry = new BEntry();
	TaskList	*newTaskList	= NULL;
	Task		*newTask		= NULL;
	tasks->MakeEmpty();
	taskLists->MakeEmpty();
	while (tasksDir.GetNextEntry(tmpEntry, false) == B_OK) {
		if (tmpEntry->IsDirectory()){
			newTaskList = DirectoryToList(tmpEntry);
			if (newTaskList != NULL){
				BMessage *msg = new BMessage();
				msg->AddPointer("tasklist",newTaskList);
				Looper()->SendNotices(ADD_TASK_LIST,msg);
				taskLists->AddItem(newTaskList);
			}
		}
	}
	while (tasksDir.GetNextEntry(tmpEntry, false) == B_OK) {
		if (tmpEntry->IsDirectory()){
			newTaskList = DirectoryToList(tmpEntry);
			if (newTaskList != NULL){
				BMessage *msg = new BMessage();
				msg->AddPointer("tasklist",newTaskList);
				Looper()->SendNotices(ADD_TASK_LIST,msg);
				taskLists->AddItem(newTaskList);
			}
		}
	}
	tasksDir.Rewind();
	return err;
}
开发者ID:Paradoxianer,项目名称:Tasks,代码行数:33,代码来源:TaskFS.cpp

示例2:

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

示例3: dir

int
VSTAddOn::ScanPluginsFolders(const char* path, bool make_dir)
{
	BEntry ent;

	BDirectory dir(path);
	if (dir.InitCheck() != B_OK) {
		create_directory(path, 0755);
		return 0;
	}

	while(dir.GetNextEntry(&ent) == B_OK) {
		BPath p(&ent);
		if (ent.IsDirectory()) {
			ScanPluginsFolders(p.Path());
		} else {
			VSTPlugin* plugin = new VSTPlugin();
			int ret = plugin->LoadModule(p.Path());
			if (ret == B_OK) {
				plugin->UnLoadModule();
				fPluginsList.AddItem(plugin);				
			} else
				delete plugin;
		}
	}
	return 0;
}
开发者ID:Barrett17,项目名称:haiku-contacts-kit-old,代码行数:27,代码来源:VSTAddOn.cpp

示例4: directory

void
NetServer::_ConfigureDevices(int socket, const char* startPath,
	BMessage* suggestedInterface)
{
	BDirectory directory(startPath);
	BEntry entry;
	while (directory.GetNextEntry(&entry) == B_OK) {
		char name[B_FILE_NAME_LENGTH];
		struct stat stat;
		BPath path;
		if (entry.GetName(name) != B_OK
			|| !strcmp(name, "stack")
			|| entry.GetPath(&path) != B_OK
			|| entry.GetStat(&stat) != B_OK)
			continue;

		if (S_ISBLK(stat.st_mode) || S_ISCHR(stat.st_mode)) {
			if (suggestedInterface != NULL
				&& suggestedInterface->RemoveName("device") == B_OK
				&& suggestedInterface->AddString("device", path.Path()) == B_OK
				&& _ConfigureInterface(socket, *suggestedInterface) == B_OK)
				suggestedInterface = NULL;
			else
				_ConfigureDevice(socket, path.Path());
		} else if (entry.IsDirectory())
			_ConfigureDevices(socket, path.Path(), suggestedInterface);
	}
}
开发者ID:mmanley,项目名称:Antares,代码行数:28,代码来源:NetServer.cpp

示例5: while

void
OpenWindow::CollectDevices(BMenu *menu, BEntry *startEntry)
{
    BDirectory directory;
    if (startEntry != NULL)
        directory.SetTo(startEntry);
    else
        directory.SetTo("/dev/disk");

    BEntry entry;
    while (directory.GetNextEntry(&entry) == B_OK) {
        if (entry.IsDirectory()) {
            CollectDevices(menu, &entry);
            continue;
        }

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

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

        BMessage *message = new BMessage(B_REFS_RECEIVED);
        message->AddRef("refs", &ref);

        menu->AddItem(new BMenuItem(path.Path(), message));
    }
}
开发者ID:simonsouth,项目名称:haiku,代码行数:30,代码来源:OpenWindow.cpp

示例6: GetDirectorySize

uint64 PanelView::GetDirectorySize(const char *path)
////////////////////////////////////////////////////////////////////////
{
	uint64 size = 0;
	BDirectory *dir;
		
	dir = new BDirectory(path);
	if (dir)
	{
		BEntry entry;
		
		if (dir->GetEntry(&entry)==B_OK)
		{	
			while (dir->GetNextEntry(&entry)==B_OK)			
			{
				BPath path;
				entry.GetPath(&path);
				
				if (entry.IsDirectory())
					size += GetDirectorySize(path.Path());
				else
				{
					struct stat statbuf;
					entry.GetStat(&statbuf);
					
					size += statbuf.st_size;
				}	
			}
		}
	
		delete dir;
	}

	return size;
}
开发者ID:PZsolt27,项目名称:GenesisCommander,代码行数:35,代码来源:GenesisPanelView.cpp

示例7: if

//---------------------- Private ---------------------------------//
status_t
JoyWin::_AddToList(BListView *list, uint32 command, const char* rootPath,
	BEntry *rootEntry)
{
	BDirectory root;

	if ( rootEntry != NULL )
		root.SetTo( rootEntry );
	else if ( rootPath != NULL )
		root.SetTo( rootPath );
	else
		return B_ERROR;

	BEntry entry;
	while ((root.GetNextEntry(&entry)) > B_ERROR ) {
		if (entry.IsDirectory()) {
			_AddToList(list, command, rootPath, &entry);
		} else {
			BPath path;
			entry.GetPath(&path);
			BString str(path.Path());
			str.RemoveFirst(rootPath);
			list->AddItem(new PortItem(str.String()));
		}
	}
	return B_OK;
}
开发者ID:Barrett17,项目名称:haiku-contacts-kit-old,代码行数:28,代码来源:JoyWin.cpp

示例8: AddEntry

bool SeqNavMenu::AddEntry(BEntry& entry, bool useLeafForLabel)
{
	BPath			path;
	if( entry.GetPath( &path ) != B_OK ) {
		printf("\tquery returned an entry but couldn't get the path\n");
		return false;
	}
	const char*		label = (useLeafForLabel) ? path.Leaf(): path.Path();
	if( !label ) return false;
	_AmIconMenuItem* item = 0;
	uint32			tmpEntry;
	if( entry.IsDirectory() ) {
		tmpEntry = DIR_ENTRY;
		SeqNavMenu*	nm = new SeqNavMenu( label, mTarget );
		if( nm && (item = new _AmIconMenuItem( nm )) ) {
			nm->SetPath( path.Path() );
		}
	} else {
		tmpEntry = OTHER_ENTRY;
		BMessage*		msg = new BMessage( B_REFS_RECEIVED );
		entry_ref		ref;
		if( msg && (entry.GetRef( &ref ) == B_OK) ) {
			msg->AddRef( "refs", &ref );
			item = new _AmIconMenuItem( label, msg );
		}
	}

	if( item ) {
		mItems.push_back( item );
		item->SetIcon( GetIcon( entry ) );
		if( mFirstEntry == NO_ENTRY ) mFirstEntry = tmpEntry;
	}
	return true;
}
开发者ID:HaikuArchives,项目名称:Sequitur,代码行数:34,代码来源:SeqNavMenu.cpp

示例9: dir

status_t
ACPIDriverInterface::_FindDrivers(const char* path)
{
	BDirectory dir(path);
	BEntry entry;

	status_t status = B_ERROR;

	while (dir.GetNextEntry(&entry) == B_OK) {
		BPath path;
		entry.GetPath(&path);

		if (entry.IsDirectory()) {
			if (_FindDrivers(path.Path()) == B_OK)
				return B_OK;
		}
		else {
			int32 handler = open(path.Path(), O_RDWR);
			if (handler >= 0) {
				printf("try %s\n", path.Path());
				Battery* battery = new Battery(handler);
				if (battery->InitCheck() == B_OK) {
					fDriverList.AddItem(battery);
					status = B_OK;
				}
				else
					delete battery;
			}
		}

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

示例10: if

void
ModuleManager::_FindModules(BDirectory &dir, const char *moduleDir,
	const char *suffix, module_name_list *list)
{
	BEntry entry;
	while (dir.GetNextEntry(&entry) == B_OK) {
		if (entry.IsFile()) {
			ModuleAddOn addon;
			BPath path;
			if (entry.GetPath(&path) == B_OK
				&& addon.Load(path.Path(), moduleDir) == B_OK) {
				module_info **infos = addon.ModuleInfos();
				for (int32 i = 0; infos[i]; i++) {
					if (infos[i]->name
						&& _MatchSuffix(infos[i]->name, suffix))
						list->names.insert(infos[i]->name);
				}
			}
		} else if (entry.IsDirectory()) {
			BDirectory subdir;
			if (subdir.SetTo(&entry) == B_OK)
				_FindModules(subdir, moduleDir, suffix, list);
		}
	}
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:25,代码来源:module.cpp

示例11: dir

status_t
CPUFreqDriverInterface::_FindSpeedStepDriver(const char* path)
{
	BDirectory dir(path);
	BEntry entry;
	
	while (dir.GetNextEntry(&entry) == B_OK) {
		BPath path;
		entry.GetPath(&path);
		
		if (entry.IsDirectory()) {
			if (_FindSpeedStepDriver(path.Path()) == B_OK)
				return B_OK;
		}
		else {
			fDriverHandler = open(path.Path(), O_RDWR);
			if (fDriverHandler >= 0) {
				uint32 magicId = 0;
				status_t ret;
				ret = ioctl(fDriverHandler, IDENTIFY_DEVICE, &magicId,
								sizeof(uint32));
				if (ret == B_OK && magicId == kMagicFreqID)
					return B_OK;
				else
					close(fDriverHandler);
			}
		}
		
	}
	return B_ERROR;	
}
开发者ID:mmanley,项目名称:Antares,代码行数:31,代码来源:DriverInterface.cpp

示例12: tryDir

/*
 * This function is lifted from Simple Directmedia Layer (SDL):
 *  http://www.libsdl.org/
 */
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);
        } /* if */

        else
        {
            bool add_it = false;
            int devfd;
            device_geometry g;

            if (strcmp(e.name, "raw") == 0)  /* ignore partitions. */
            {
                int devfd = open(name, O_RDONLY);
                if (devfd >= 0)
                {
                    if (ioctl(devfd, B_GET_GEOMETRY, &g, sizeof(g)) >= 0)
                    {
                        if (g.device_type == B_CD)
                        {
                            char *mntpnt = getMountPoint(name);
                            if (mntpnt != NULL)
                            {
                                callback(data, mntpnt);
                                allocator.Free(mntpnt);  /* !!! FIXME: lose this malloc! */
                            } /* if */
                        } /* if */
                    } /* if */
                } /* if */
            } /* if */

            close(devfd);
        } /* else */
    } /* while */
} /* tryDir */
开发者ID:BackupTheBerlios,项目名称:netpanzer-svn,代码行数:63,代码来源:beos.cpp

示例13:

void
LaunchDaemon::_ReadEntry(const char* context, BEntry& entry)
{
	if (entry.IsDirectory())
		_ReadDirectory(context, entry);
	else
		_ReadFile(context, entry);
}
开发者ID:garodimb,项目名称:haiku,代码行数:8,代码来源:LaunchDaemon.cpp

示例14: dir

int32
CDAudioDevice::_FindDrives(const char *path)
{
	BDirectory dir(path);

	if (dir.InitCheck() != B_OK)
		return B_ERROR; 

	dir.Rewind();

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

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

		name = path.Path();
		if (entry.GetRef(&e) != B_OK)
			continue;

		if (entry.IsDirectory()) {
			// ignore floppy -- it is not silent
			if (strcmp(e.name, "floppy") == 0)
				continue;
			else if (strcmp(e.name, "ata") == 0)
				continue;

			// Note that if we check for the count here, we could
			// just search for one drive. However, we want to find *all* drives
			// that are available, so we keep searching even if we've found one
			_FindDrives(name);

		} else {
			int devfd;
			device_geometry g;

			// ignore partitions
			if (strcmp(e.name, "raw") != 0)
				continue;

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

			if (ioctl(devfd, B_GET_GEOMETRY, &g, sizeof(g)) >= 0) {
				if (g.device_type == B_CD)
					fDriveList.AddItem(new BString(name));
			}
			close(devfd);
		}
	}
	return fDriveList.CountItems();
}
开发者ID:mmanley,项目名称:Antares,代码行数:56,代码来源:CDAudioDevice.cpp

示例15: if

void
PathHandler::_EntryCreated(BMessage* message)
{
	const char* name;
	node_ref nodeRef;
	if (message->FindInt32("device", &nodeRef.device) != B_OK
		|| message->FindInt64("directory", &nodeRef.node) != B_OK
		|| message->FindString("name", &name) != B_OK) {
		TRACE("PathHandler::_EntryCreated() - malformed message!\n");
		return;
	}

	BEntry entry;
	if (set_entry(nodeRef, name, entry) != B_OK) {
		TRACE("PathHandler::_EntryCreated() - set_entry failed!\n");
		return;
	}

	bool parentContained = false;
	bool entryContained = _IsContained(entry);
	if (entryContained)
		parentContained = _IsContained(nodeRef);
	bool notify = entryContained;

	if (entry.IsDirectory()) {
		// ignore the directory if it's already known
		if (entry.GetNodeRef(&nodeRef) == B_OK
			&& _HasDirectory(nodeRef)) {
			TRACE("    WE ALREADY HAVE DIR %s, %ld:%Ld\n",
				name, nodeRef.device, nodeRef.node);
			return;
		}

		// a new directory to watch for us
		if ((!entryContained && !_CloserToPath(entry))
			|| (parentContained && !_WatchRecursively())
			|| _AddDirectory(entry, true) != B_OK
			|| _WatchFilesOnly())
			notify = parentContained;
		// NOTE: entry is now toast after _AddDirectory() was called!
		// Does not matter right now, but if it's a problem, use the node_ref
		// version...
	} else if (entryContained) {
		TRACE("  NEW ENTRY PARENT CONTAINED: %d\n", parentContained);
		_AddFile(entry);
	}

	if (notify && entryContained) {
		message->AddBool("added", true);
		// nodeRef is pointing to the parent directory
		entry.GetNodeRef(&nodeRef);
		_NotifyTarget(message, nodeRef);
	}
}
开发者ID:mmanley,项目名称:Antares,代码行数:54,代码来源:PathMonitor.cpp


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