本文整理汇总了C++中BDirectory类的典型用法代码示例。如果您正苦于以下问题:C++ BDirectory类的具体用法?C++ BDirectory怎么用?C++ BDirectory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BDirectory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void
BNavMenu::BuildVolumeMenu()
{
BVolumeRoster roster;
BVolume volume;
roster.Rewind();
while (roster.GetNextVolume(&volume) == B_OK) {
if (!volume.IsPersistent())
continue;
BDirectory startDir;
if (volume.GetRootDirectory(&startDir) == B_OK) {
BEntry entry;
startDir.GetEntry(&entry);
Model *model = new Model(&entry);
if (model->InitCheck() != B_OK) {
delete model;
continue;
}
BNavMenu *menu = new BNavMenu(model->Name(), fMessage.what,
fMessenger, fParentWindow, fTypesList);
menu->SetNavDir(model->EntryRef());
ASSERT(menu->Name());
ModelMenuItem *item = new ModelMenuItem(model, menu);
BMessage *message = new BMessage(fMessage);
message->AddRef("refs", model->EntryRef());
item->SetMessage(message);
fItemList->AddItem(item);
ASSERT(item->Label());
}
}
}
示例2: while
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;
}
示例3: InitCheck
status_t
BPrinter::SetTo(const BDirectory& directory)
{
StopWatching();
BEntry entry;
directory.GetEntry(&entry);
entry.GetRef(&fPrinterEntryRef);
return InitCheck();
}
示例4: 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;
}
示例5: delete_directory_path
void
delete_directory_path(char *path,bool recur)
{
BDirectory *dir;
BPath *pat,pt;
BEntry *ent;
if ((pat = create_path(path)))
{
if ((dir = create_mydir((char *)pat->Path())))
{
if (dir->Rewind() == B_OK)
{
if ((ent = new BEntry()))
{
while (dir->GetNextEntry(ent,false) == B_NO_ERROR)
{
if (ent->GetPath(&pt) == B_NO_ERROR)
{
if (recur)
{
if (ent->IsDirectory())
{
delete_directory_path((char *)pt.Path(),recur);
}
}
}
ent->Remove();
}
delete ent;
}
}
delete dir;
}
delete pat;
}
}
示例6: find_directory
void
TTracker::InstallTemporaryBackgroundImages()
{
// make the large Haiku Logo the default background
BPath path;
status_t status = find_directory(B_SYSTEM_DATA_DIRECTORY, &path);
if (status < B_OK) {
// TODO: this error shouldn't be shown to the regular user
BString errorMessage(B_TRANSLATE("At %func \nfind_directory() "
"failed. \nReason: %error"));
errorMessage.ReplaceFirst("%func", __PRETTY_FUNCTION__);
errorMessage.ReplaceFirst("%error", strerror(status));
BAlert* alert = new BAlert("AlertError", errorMessage.String(),
B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
alert->Go();
return;
}
path.Append("artwork");
BString defaultBackgroundImage("/HAIKU logo - white on blue - big.png");
BDirectory dir;
if (FSGetBootDeskDir(&dir) == B_OK) {
// install a default background if there is no background defined yet
attr_info info;
if (dir.GetAttrInfo(kBackgroundImageInfo, &info) != B_OK) {
BScreen screen(B_MAIN_SCREEN_ID);
BPoint logoPos;
logoPos.x
= floorf((screen.Frame().Width() - 605) * (sqrtf(5) - 1) / 2);
logoPos.y = floorf((screen.Frame().Height() - 190) * 0.9);
BMessage message;
AddTemporaryBackgroundImages(&message,
(BString(path.Path()) << defaultBackgroundImage).String(),
BackgroundImage::kAtOffset, logoPos, 0xffffffff, false);
::InstallTemporaryBackgroundImages(&dir, &message);
}
}
}
示例7: PRINT
status_t
ThemeManager::LoadTheme(const char *path, BMessage **to)
{
status_t err;
BDirectory dir;
BFile f;
BMessage *theme;
#ifdef DEBUG_TM
PRINT(("ThemeManager::%s(%s)\n", __FUNCTION__, path));
#endif
err = dir.SetTo(path);
if (err)
fprintf(stderr, "ThemeManager:: BDirectory::SetTo 0x%08lx\n", err);
if (err) { /* not a dir, check for a zip */
// TODO
// unzip + recursive call
return err;
}
err = f.SetTo(&dir, Z_THEME_FILE_NAME, B_READ_ONLY);
if (err)
fprintf(stderr, "ThemeManager:: BFile::SetTo 0x%08lx\n", err);
if (err)
return err;
err = ParseMessageFromStream(&theme, f);
if (err)
fprintf(stderr, "ThemeManager:: ParseMessageFromStream 0x%08lx\n", err);
if (err)
return err;
err = theme->RemoveName(Z_THEME_LOCATION);
err = theme->AddString(Z_THEME_LOCATION, path);
//theme->PrintToStream();
err = AddTheme(theme);
if (err)
fprintf(stderr, "ThemeManager:: AddTheme 0x%08lx\n", err);
if (err)
delete theme;
if (!err && to)
*to = theme;
return err;
}
示例8:
void
AddOnManager::_GetReaders(const BPath& path, entry_ref* outRefs,
int32* outCount, int32 maxCount)
{
node_ref nref;
BDirectory directory;
if (directory.SetTo(path.Path()) != B_OK
|| directory.GetNodeRef(&nref) != B_OK) {
return;
}
reader_info* info;
for (fReaderList.Rewind(); fReaderList.GetNext(&info)
&& *outCount < maxCount;) {
if (info->ref.directory != nref.node)
continue;
outRefs[*outCount] = info->ref;
(*outCount)++;
}
}
示例9: memset
/* isProject
* checks if an selected folder is a lava project folder.
*/
bool
ProjectTypeSelector::isProject()
{
BNode objNode;
BString *Project = (BString*)FileList->FirstItem();
objNode.SetTo(Project->String());
char buffer[500];
memset(buffer, 0, sizeof(buffer));
if(objNode.ReadAttr("LAVA:Type", B_STRING_TYPE, 0, buffer, sizeof(buffer)) == B_ENTRY_NOT_FOUND)
return false;
else {
BDirectory objDir;
objDir.SetTo(Project->String());
if(objDir.InitCheck() != B_OK)
return false;
else
return true;
}
}
示例10: _FindBuiltInModules
// OpenModuleList
module_name_list *
ModuleManager::OpenModuleList(const char *prefix, const char *suffix)
{
module_name_list *list = NULL;
if (prefix) {
list = new module_name_list;
_FindBuiltInModules(prefix, suffix, list);
for (int32 i = 0; gModuleDirs[i]; i++) {
BPath path;
BDirectory dir;
if (path.SetTo(gModuleDirs[i], prefix) == B_OK
&& dir.SetTo(path.Path()) == B_OK) {
_FindModules(dir, gModuleDirs[i], suffix, list);
}
}
list->it = list->names.begin();
}
return list;
}
示例11: BMenuItem
void
DialUpView::LoadInterfaces()
{
fInterfaceMenu->AddSeparatorItem();
fInterfaceMenu->AddItem(new BMenuItem(kLabelCreateNewInterface,
new BMessage(kMsgCreateNew)));
fDeleterItem = new BMenuItem(kLabelDeleteCurrent,
new BMessage(kMsgDeleteCurrent));
fInterfaceMenu->AddItem(fDeleterItem);
BDirectory settingsDirectory;
BEntry entry;
BPath path;
GetPPPDirectories(&settingsDirectory, NULL);
while(settingsDirectory.GetNextEntry(&entry) == B_OK) {
if(entry.IsFile()) {
entry.GetPath(&path);
AddInterface(path.Leaf(), true);
}
}
}
示例12:
void
TMailApp::_CheckForSpamFilterExistence()
{
// Looks at the filter settings to see if the user is using a spam filter.
// If there is one there, set fShowSpamGUI to TRUE, otherwise to FALSE.
int32 addonNameIndex;
const char *addonNamePntr;
BDirectory inChainDir;
BPath path;
BEntry settingsEntry;
BFile settingsFile;
BMessage settingsMessage;
fShowSpamGUI = false;
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK)
return;
// TODO use new settings
path.Append("Mail/chains/inbound");
if (inChainDir.SetTo(path.Path()) != B_OK)
return;
while (inChainDir.GetNextEntry (&settingsEntry, true /* traverse */) == B_OK) {
if (!settingsEntry.IsFile())
continue;
if (settingsFile.SetTo (&settingsEntry, B_READ_ONLY) != B_OK)
continue;
if (settingsMessage.Unflatten (&settingsFile) != B_OK)
continue;
for (addonNameIndex = 0; B_OK == settingsMessage.FindString (
"filter_addons", addonNameIndex, &addonNamePntr);
addonNameIndex++) {
if (strstr (addonNamePntr, "Spam Filter") != NULL) {
fShowSpamGUI = true; // Found it!
return;
}
}
}
}
示例13: SysAddDiskPrefs
void SysAddDiskPrefs(void)
{
// Let BeOS scan for HFS drives
D(bug("Looking for Mac volumes...\n"));
system("mountvolume -allhfs");
// Add all HFS volumes
int32 i = 0;
dev_t d;
fs_info info;
while ((d = next_dev(&i)) >= 0) {
fs_stat_dev(d, &info);
status_t err = -1;
BPath mount;
if (!strcmp(info.fsh_name, "hfs")) {
BDirectory dir;
BEntry entry;
node_ref node;
node.device = info.dev;
node.node = info.root;
err = dir.SetTo(&node);
if (!err)
err = dir.GetEntry(&entry);
if (!err)
err = entry.GetPath(&mount);
}
if (!err)
err = unmount(mount.Path());
if (!err) {
char dev_name[B_FILE_NAME_LENGTH];
if (info.flags & B_FS_IS_READONLY) {
dev_name[0] = '*';
dev_name[1] = 0;
} else
dev_name[0] = 0;
strcat(dev_name, info.device_name);
PrefsAddString("disk", dev_name);
}
}
}
示例14: IsModified
bool
DialUpView::SaveSettingsToFile()
{
bool settingsChanged, profileChanged;
IsModified(&settingsChanged, &profileChanged);
if(!settingsChanged && !profileChanged)
return true;
BMessage settings, profile;
if(!SaveSettings(&settings, &profile, false))
return false;
BDirectory settingsDirectory;
BDirectory profileDirectory;
GetPPPDirectories(&settingsDirectory, &profileDirectory);
if(settingsDirectory.InitCheck() != B_OK || profileDirectory.InitCheck() != B_OK)
return false;
BFile file;
if(settingsChanged) {
settingsDirectory.CreateFile(fCurrentItem->Label(), &file);
WriteMessageDriverSettings(file, settings);
}
if(profileChanged) {
profileDirectory.CreateFile(fCurrentItem->Label(), &file);
WriteMessageDriverSettings(file, profile);
}
return true;
}
示例15: while
void
VirtualKeyboardWindow::_LoadLayoutMenu(BMenu* menu, BDirectory directory)
{
entry_ref ref;
while (directory.GetNextRef(&ref) == B_OK) {
if (menu->FindItem(ref.name) != NULL)
continue;
BDirectory subdirectory;
subdirectory.SetTo(&ref);
if (subdirectory.InitCheck() == B_OK) {
BMenu* submenu = new BMenu(ref.name);
_LoadLayoutMenu(submenu, subdirectory);
menu->AddItem(submenu);
} else {
//BMessage* message = new BMessage(kChangeKeyboardLayout);
//message->AddRed("ref",&ref);
menu->AddItem(new BMenuItem(ref.name, NULL));
}
}
}