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


C++ BDirectory::GetNextEntry方法代码示例

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


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

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

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

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

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

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

示例6: scan_for_cdrom_drives

// Scan directory for CD-ROM drives, add them to prefs
static void scan_for_cdrom_drives(const char *directory)
{
	// Set directory
	BDirectory dir;
	dir.SetTo(directory);
	if (dir.InitCheck() != B_NO_ERROR)
		return;
	dir.Rewind();

	// Scan each entry
	BEntry entry;
	while (dir.GetNextEntry(&entry) >= 0) {

		// Get path and ref for entry
		BPath path;
		if (entry.GetPath(&path) != B_NO_ERROR)
			continue;
		const char *name = path.Path();
		entry_ref e;
		if (entry.GetRef(&e) != B_NO_ERROR)
			continue;

		// Recursively enter subdirectories (except for floppy)
		if (entry.IsDirectory()) {
			if (!strcmp(e.name, "floppy"))
				continue;
			scan_for_cdrom_drives(name);
		} else {

			D(bug(" checking '%s'\n", name));

			// Ignore partitions
			if (strcmp(e.name, "raw"))
				continue;

			// Open device
			int fd = open(name, O_RDONLY);
			if (fd < 0)
				continue;

			// Get geometry and device type
			device_geometry g;
			if (ioctl(fd, B_GET_GEOMETRY, &g, sizeof(g)) < 0) {
				close(fd);
				continue;
			}

			// Insert to list if it is a CD drive
			if (g.device_type == B_CD)
				PrefsAddString("cdrom", name);
			close(fd);
		}
	}
}
开发者ID:AlexandreCo,项目名称:macemu,代码行数:55,代码来源:sys_beos.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: 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

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

示例10:

/*!	\brief Scan a folder for all valid fonts
	\param directoryPath Path of the folder to scan.
*/
status_t
FontManager::_ScanFontDirectory(font_directory& fontDirectory)
{
	// This bad boy does all the real work. It loads each entry in the
	// directory. If a valid font file, it adds both the family and the style.

	BDirectory directory;
	status_t status = directory.SetTo(&fontDirectory.directory);
	if (status != B_OK)
		return status;

	BEntry entry;
	while (directory.GetNextEntry(&entry) == B_OK) {
		if (entry.IsDirectory()) {
			// scan this directory recursively
			font_directory* newDirectory;
			if (_AddPath(entry, &newDirectory) == B_OK && newDirectory != NULL)
				_ScanFontDirectory(*newDirectory);

			continue;
		}

// TODO: Commenting this out makes my "Unicode glyph lookup"
// work with our default fonts. The real fix is to select the
// Unicode char map (if supported), and/or adjust the
// utf8 -> glyph-index mapping everywhere to handle other
// char maps. We could also ignore fonts that don't support
// the Unicode lookup as a temporary "solution".
#if 0
		FT_CharMap charmap = _GetSupportedCharmap(face);
		if (!charmap) {
		    FT_Done_Face(face);
		    continue;
    	}

		face->charmap = charmap;
#endif

		_AddFont(fontDirectory, entry);
			// takes over ownership of the FT_Face object
	}

	fontDirectory.revision = 1;
	return B_OK;
}
开发者ID:mariuz,项目名称:haiku,代码行数:48,代码来源:FontManager.cpp

示例11: SavedGames

void BeCheckersWindow::SavedGames(BListView *list) {
	char name[B_FILE_NAME_LENGTH];

	BEntry entry;
	BDirectory dir;
	BPath p;
	find_directory(B_USER_DIRECTORY, &p);
	p.Append(APP_SGP);

	dir.SetTo(p.Path());
	dir.Rewind();

	while (dir.GetNextEntry(&entry) == B_OK) {
		entry.GetName(name);
		strtok(name, ".");	// Strip the filename extension
		list->AddItem(new BStringItem(name));
	}
}
开发者ID:noryb009,项目名称:BeCheckers,代码行数:18,代码来源:BeCheckersWindow.cpp

示例12: DeleteDirectory

void PanelView::DeleteDirectory(const char *dirname)
////////////////////////////////////////////////////////////////////////
{
	BDirectory *dir;
	key_info keyinfo;
	
	// Don't delete the parent directory!!!!!!
	if (strlen(dirname)>=3)
	{
		int len = strlen(dirname);
		if (dirname[len-1]=='.' && dirname[len-2]=='.' && dirname[len-3]=='/') return;
	}
		
	dir = new BDirectory(dirname);
	if (dir)
	{
		BEntry entry;
		
		if (dir->GetEntry(&entry)==B_OK)
		{	
			while (dir->GetNextEntry(&entry)==B_OK)			
			{
				get_key_info(&keyinfo);
				if (keyinfo.key_states[0] & 0x40)	// ESC
				{
					beep();
					delete dir;
					return;
				}

				BPath path;
				entry.GetPath(&path);
				
				if (entry.IsDirectory())
					DeleteDirectory(path.Path());

				entry.Remove();
			}
		}
	
		delete dir;
	}
}
开发者ID:PZsolt27,项目名称:GenesisCommander,代码行数:43,代码来源:GenesisPanelView.cpp

示例13: subDir

// collect_folder_contents
void
collect_folder_contents( BDirectory& dir, BList& list, bool& deep, bool& asked, BEntry& entry )
{
    while ( dir.GetNextEntry( &entry, true ) == B_OK )
    {
        if ( !entry.IsDirectory() )
        {
            BPath path;
            // since the directory will give us the entries in reverse order,
            // we put them each at the same index, effectively reversing the
            // items while adding them
            if ( entry.GetPath( &path ) == B_OK )
            {
                BString* string = new BString( path.Path() );
                if ( !list.AddItem( string, 0 ) )
                    delete string;    // at least don't leak
            }
        }
        else
        {
            if ( !asked )
            {
                // ask user if we should parse sub-folders as well
                BAlert* alert = new BAlert( "sub-folders?",
                                            _("Open files from all sub-folders as well?"),
                                            _("Cancel"), _("Open"), NULL, B_WIDTH_AS_USUAL,
                                            B_IDEA_ALERT );
                int32 buttonIndex = alert->Go();
                deep = buttonIndex == 1;
                asked = true;
                // never delete BAlerts!!
            }
            if ( deep )
            {
                BDirectory subDir( &entry );
                if ( subDir.InitCheck() == B_OK )
                    collect_folder_contents( subDir, list,
                                             deep, asked, entry );
            }
        }
    }
}
开发者ID:FLYKingdom,项目名称:vlc,代码行数:43,代码来源:InterfaceWindow.cpp

示例14: LoadModules

status_t HModuleRoster::LoadModules( BPath *moduleDirectory )
{
	status_t		status;
	BDirectory		dir;
	
	if( (status = dir.SetTo( moduleDirectory->Path() )) == B_OK )
	{
		BEntry		entry;
		BPath		modulePath;
		
		while( dir.GetNextEntry( &entry, true ) != B_ENTRY_NOT_FOUND )
		{
			entry.GetPath( &modulePath );
			LoadModule( &modulePath );
		}
	}
	else
		return status;
	return B_OK;
}
开发者ID:HaikuArchives,项目名称:RobinHood,代码行数:20,代码来源:HModuleRoster.cpp

示例15:

bool
BTrashWatcher::CheckTrashDirs()
{
	BVolumeRoster volRoster;
	volRoster.Rewind();
	BVolume	volume;
	while (volRoster.GetNextVolume(&volume) == B_OK) {
		if (volume.IsReadOnly() || !volume.IsPersistent())
			continue;

		BDirectory trashDir;
		FSGetTrashDir(&trashDir, volume.Device());
		trashDir.Rewind();
		BEntry entry;
		if (trashDir.GetNextEntry(&entry) == B_OK)
			return true;
	}

	return false;
}
开发者ID:Barrett17,项目名称:haiku-contacts-kit-old,代码行数:20,代码来源:TrashWatcher.cpp


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