本文整理汇总了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;
}
示例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);
}
}
}
示例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));
}
}
示例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;
}
示例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 */
示例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);
}
}
}
示例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));
}
}
}
示例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 */
示例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++;
}
}
示例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;
}
示例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));
}
}
示例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;
}
}
示例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 );
}
}
}
}
示例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;
}
示例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;
}