本文整理汇总了C++中BEntry::IsFile方法的典型用法代码示例。如果您正苦于以下问题:C++ BEntry::IsFile方法的具体用法?C++ BEntry::IsFile怎么用?C++ BEntry::IsFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BEntry
的用法示例。
在下文中一共展示了BEntry::IsFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mediaFilePath
// _BindExtraMedia() searches additional videos and audios
// and addes them as extra medias.
/*static*/ void
Playlist::_BindExtraMedia(PlaylistItem* item)
{
FilePlaylistItem* fileItem = dynamic_cast<FilePlaylistItem*>(item);
if (!fileItem)
return;
// If the media file is foo.mp3, _BindExtraMedia() searches foo.avi.
BPath mediaFilePath(&fileItem->Ref());
BString mediaFilePathString = mediaFilePath.Path();
BPath dirPath;
mediaFilePath.GetParent(&dirPath);
BDirectory dir(dirPath.Path());
if (dir.InitCheck() != B_OK)
return;
BEntry entry;
BString entryPathString;
while (dir.GetNextEntry(&entry, true) == B_OK) {
if (!entry.IsFile())
continue;
entryPathString = BPath(&entry).Path();
if (entryPathString != mediaFilePathString
&& _GetExceptExtension(entryPathString) == _GetExceptExtension(mediaFilePathString)) {
_BindExtraMedia(fileItem, entry);
}
}
}
示例2: address
/***********************************************************
* SetFrom
***********************************************************/
void
HAddressView::SetFrom(const char* in_address)
{
if( ::strlen(in_address) == 0)
return;
BString address(in_address);
// Compare existing accounts
char name[B_FILE_NAME_LENGTH];
BPath path;
::find_directory(B_USER_SETTINGS_DIRECTORY,&path);
path.Append(APP_NAME);
path.Append("Accounts");
BDirectory dir(path.Path());
status_t err = B_OK;
BEntry entry;
bool changed = false;
while(err == B_OK)
{
if( (err = dir.GetNextEntry(&entry)) != B_OK )
break;
BFile file(&entry,B_READ_ONLY);
if(file.InitCheck() == B_OK && entry.IsFile())
{
BMessage msg;
msg.Unflatten(&file);
BString myAddress;
PRINT(("%s\n",in_address));
if(msg.FindString("address",&myAddress) != B_OK)
myAddress = "";
// Change account
if(address.FindFirst(myAddress) != B_ERROR)
{
entry.GetName(name);
ChangeAccount(name);
// Set From menu
BMenuField *field = cast_as(FindView("FromMenu"),BMenuField);
BMenu *menu = field->Menu();
BMenuItem *item = menu->FindItem(name);
if(item)
item->SetMarked(true);
changed=true;
break;
}
}
}
if(!changed && cast_as(Window()->FindView("HMailView"),BTextView))
{
BMenuField *field = cast_as(FindView("FromMenu"),BMenuField);
BMenuItem *item(NULL);
item = field->Menu()->FindMarked();
if(item)
{
ChangeAccount(item->Label());
item->SetMarked(true);
}
}
}
示例3: BString
void
LiveQuery::_PerformQuery(BQuery& query)
{
status_t status = query.Fetch();
if (status != B_OK) {
fprintf(stderr, "%s: bad query expression\n", kProgramName);
return;
}
int32 count = 0;
BEntry entry;
BPath path;
while (query.GetNextEntry(&entry) == B_OK) {
if (sFilesOnly && !entry.IsFile())
continue;
if (entry.GetPath(&path) != B_OK) {
fprintf(stderr, "%s: could not get path for entry\n", kProgramName);
continue;
}
printf("%s\n", sEscapeMetaChars ? BString().CharacterEscape(
path.Path(), " ()?*&\"'[]^\\~|;!<>*$\t", '\\').String()
: path.Path());
count++;
}
printf("FOUND %ld entries\n", count);
}
示例4: 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);
}
}
}
示例5: 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());
}
}
示例6: SyncMailbox
void BMailRemoteStorageProtocol::SyncMailbox(const char *mailbox) {
BPath path(runner->Chain()->MetaData()->FindString("path"));
path.Append(mailbox);
BDirectory folder(path.Path());
BEntry entry;
BFile snoodle;
BString string;
uint32 chain;
bool append;
while (folder.GetNextEntry(&entry) == B_OK) {
if (!entry.IsFile())
continue;
while (snoodle.SetTo(&entry,B_READ_WRITE) == B_BUSY) snooze(100);
append = false;
while (snoodle.Lock() != B_OK) snooze(100);
snoodle.Unlock();
if (snoodle.ReadAttr("MAIL:chain",B_INT32_TYPE,0,&chain,sizeof(chain)) < B_OK)
append = true;
if (chain != runner->Chain()->ID())
append = true;
if (snoodle.ReadAttrString("MAIL:unique_id",&string) < B_OK)
append = true;
BString folder(string), id("");
int32 j = string.FindLast('/');
if ((!append) && (j >= 0)) {
folder.Truncate(j);
string.CopyInto(id,j + 1,string.Length());
if (folder == mailbox)
continue;
} else {
append = true;
}
if (append)
AddMessage(mailbox,&snoodle,&id); //---We should check for partial messages here
else
CopyMessage(folder.String(),mailbox,&id);
string = mailbox;
string << '/' << id;
/*snoodle.RemoveAttr("MAIL:unique_id");
snoodle.RemoveAttr("MAIL:chain");*/
chain = runner->Chain()->ID();
snoodle.WriteAttr("MAIL:chain",B_INT32_TYPE,0,&chain,sizeof(chain));
snoodle.WriteAttrString("MAIL:unique_id",&string);
(*manifest) += string.String();
(*unique_ids) += string.String();
string = runner->Chain()->Name();
snoodle.WriteAttrString("MAIL:account",&string);
}
}
示例7: sizeof
// --------------------------------------------------
status_t
Fonts::LookupFontFiles(BPath path)
{
BDirectory dir(path.Path());
BEntry entry;
if (dir.InitCheck() != B_OK)
return B_ERROR;
dir.Rewind();
while (dir.GetNextEntry(&entry) >= 0) {
BPath name;
char fn[512];
font_type ft = unknown_type; // to keep the compiler silent.
off_t size;
status_t status;
entry.GetPath(&name);
if (entry.IsDirectory())
// recursivly lookup in sub-directories...
LookupFontFiles(name);
if (! entry.IsFile())
continue;
fn[0] = 0;
ft = unknown_type;
// is it a truetype file?
status = ttf_get_fontname(name.Path(), fn, sizeof(fn));
if (status == B_OK ) {
ft = true_type_type;
} else {
// okay, maybe it's a postscript type file?
status = psf_get_fontname(name.Path(), fn, sizeof(fn));
if (status == B_OK) {
ft = type1_type;
}
}
if (ft == unknown_type)
// not a font file...
continue;
if (entry.GetSize(&size) != B_OK)
size = 1024*1024*1024;
REPORT(kDebug, -1, "Installed font %s -> %s", fn, name.Path());
fFontFiles.AddItem(new FontFile(fn, name.Path(), size, ft, size < 100*1024));
} // while dir.GetNextEntry()...
return B_OK;
}
示例8: directory
void
IMAPFolder::_ReadFolderState()
{
BDirectory directory(&fRef);
BEntry entry;
while (directory.GetNextEntry(&entry) == B_OK) {
entry_ref ref;
BNode node;
if (!entry.IsFile() || entry.GetRef(&ref) != B_OK
|| node.SetTo(&entry) != B_OK)
continue;
uint32 uidValidity = _ReadUniqueIDValidity(node);
if (uidValidity != fUIDValidity) {
// TODO: add file to mailbox
continue;
}
uint32 uid = _ReadUniqueID(node);
uint32 flags = _ReadFlags(node);
MutexLocker locker(fLock);
if (fQuitFolderState)
return;
fRefMap.insert(std::make_pair(uid, ref));
fFlagsMap.insert(std::make_pair(uid, flags));
// // TODO: make sure a listener exists at this point!
// std::set<uint32>::iterator found = lastUIDs.find(uid);
// if (found != lastUIDs.end()) {
// // The message is still around
// lastUIDs.erase(found);
//
// uint32 flagsFound = MessageFlags(uid);
// if (flagsFound != flags) {
// // Its flags have changed locally, and need to be updated
// fListener->MessageFlagsChanged(_Token(uid), ref,
// flagsFound, flags);
// }
// } else {
// // This is a new message
// // TODO: the token must be the originating token!
// uid = fListener->MessageAdded(_Token(uid), ref);
// _WriteUniqueID(node, uid);
// }
//
}
fFolderStateInitialized = true;
mutex_unlock(&fFolderStateLock);
}
示例9: 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;
}
示例10: method
/*!
In lazy mode, the entry is marked to be rescanned on next use of any
translation method (that could make use of it).
In non-lazy mode, the translators for this entry are created directly
and listeners notified.
Called by the node monitor handling.
*/
void
BTranslatorRoster::Private::_EntryAdded(const entry_ref& ref)
{
BEntry entry;
if (entry.SetTo(&ref) != B_OK || !entry.IsFile())
return;
if (fLazyScanning) {
fRescanEntries.insert(ref);
return;
}
BMessage update(B_TRANSLATOR_ADDED);
int32 count = 0;
CreateTranslators(ref, count, &update);
_NotifyListeners(update);
}
示例11: BMessage
/***********************************************************
* Build
***********************************************************/
void
AddOnMenu::Build()
{
// Build add addons menus
if(!fPath.Path())
return;
BDirectory dir(fPath.Path());
entry_ref ref;
BEntry entry;
BList itemList;
itemList.MakeEmpty();
char name[B_FILE_NAME_LENGTH];
char shortcut = 0;
BBitmap *bitmap(NULL);
while(dir.GetNextEntry(&entry,true) == B_OK)
{
if(entry.IsFile() && entry.GetRef(&ref) == B_OK)
{
shortcut = 0;
bitmap = NULL;
BMessage *msg = new BMessage(fWhat);
msg->AddRef("refs",&ref);
// make name and shortcut
int32 nameLen = ::strlen(ref.name);
::strcpy(name,ref.name);
if(name[nameLen-2] == '-')
{
shortcut = name[nameLen-1];
name[nameLen-2] = '\0';
}
if(fUseIcon)
bitmap = GetIcon(ref);
itemList.AddItem(new IconMenuItem(name,msg,shortcut,0,bitmap));
}
}
// sort items
itemList.SortItems(SortItems);
int32 count = itemList.CountItems();
for(int32 i = 0;i < count;i++)
AddItem((IconMenuItem*)itemList.ItemAt(i));
}
示例12: dir
void
AddPrinterDialog::_FillMenu(BMenu* menu, const char* path, uint32 what)
{
for (uint32 i = 0; i < sizeof(gAddonDirs) / sizeof(directory_which); i++) {
BPath addonPath;
if (find_directory(gAddonDirs[i], &addonPath) != B_OK)
continue;
if (addonPath.Append(path) != B_OK)
continue;
BDirectory dir(addonPath.Path());
if (dir.InitCheck() != B_OK)
continue;
BEntry entry;
while (dir.GetNextEntry(&entry, true) == B_OK) {
if (!entry.IsFile())
continue;
BNode node(&entry);
if (node.InitCheck() != B_OK)
continue;
BNodeInfo info(&node);
if (info.InitCheck() != B_OK)
continue;
char type[B_MIME_TYPE_LENGTH + 1];
info.GetType(type);
BMimeType entryType(type);
// filter non executable entries (like "transport" subfolder...)
if (entryType == B_APP_MIME_TYPE) {
BPath transportPath;
if (entry.GetPath(&transportPath) != B_OK)
continue;
BMessage* msg = new BMessage(what);
msg->AddString("name", transportPath.Leaf());
menu->AddItem(new BMenuItem(transportPath.Leaf(), msg));
}
}
}
}
示例13: directory
status_t
GLRendererRoster::AddPath(const char* path)
{
BDirectory directory(path);
status_t status = directory.InitCheck();
if (status < B_OK)
return status;
// if a subdirectory for our ABI exists, use that instead
if (fABISubDirectory != NULL) {
BEntry entry(&directory, fABISubDirectory);
if (entry.IsDirectory()) {
status = directory.SetTo(&entry);
if (status != B_OK)
return status;
}
}
node_ref nodeRef;
status = directory.GetNodeRef(&nodeRef);
if (status < B_OK)
return status;
int32 count = 0;
int32 files = 0;
entry_ref ref;
BEntry entry;
while (directory.GetNextRef(&ref) == B_OK) {
entry.SetTo(&ref, true);
if (entry.InitCheck() == B_OK && !entry.IsFile())
continue;
if (CreateRenderer(ref) == B_OK)
count++;
files++;
}
if (files != 0 && count == 0)
return B_BAD_VALUE;
return B_OK;
}
示例14: LoadPasswords
void ProtocolHandler::LoadPasswords()
{
//find settings dir
BPath passwordPath;
find_directory(B_USER_SETTINGS_DIRECTORY, &passwordPath);
//append Bme path and Cache path
passwordPath.Append(K_BME_SETTINGS_PATH);
passwordPath.Append(K_CACHE_PATH);
//loop through Bme Cache path and find all login names with saved passwords
BDirectory cacheDir(passwordPath.Path());
int32 entryNum = cacheDir.CountEntries();
//compose list of loginNames with passwords
for (int32 i = 0; i < entryNum;i++)
{
BEntry entry;
cacheDir.GetNextEntry(&entry);
//only open if it is a file!!!
if (entry.IsFile())
{
BFile settingsFile(&entry, B_READ_ONLY);
//data is stored as BMessages
BMessage message;
message.Unflatten(&settingsFile);
//see if password is stored in message
BString password;
BMessage userMessage;
if (message.FindMessage("user",&userMessage) == B_OK)
{
if (userMessage.FindString("User::password",&password) == B_OK)
{
BString loginName;
if (userMessage.FindString("Contact::passport" ,&loginName) == B_OK)
{
Login login = {loginName,password};
m_passwords.push_back(login);
}
}
}
}
}
}
示例15: BMessage
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);
}
}
}