本文整理汇总了C++中BDirectory::Contains方法的典型用法代码示例。如果您正苦于以下问题:C++ BDirectory::Contains方法的具体用法?C++ BDirectory::Contains怎么用?C++ BDirectory::Contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BDirectory
的用法示例。
在下文中一共展示了BDirectory::Contains方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: entry
bool
RealNameAttributeText::CommitEditedTextFlavor(BTextView* textView)
{
const char* text = textView->Text();
BEntry entry(fModel->EntryRef());
if (entry.InitCheck() != B_OK)
return false;
BDirectory parent;
if (entry.GetParent(&parent) != B_OK)
return false;
bool removeExisting = false;
if (parent.Contains(text)) {
BAlert* alert = new BAlert("",
B_TRANSLATE("That name is already taken. "
"Please type another one."),
B_TRANSLATE("Replace other file"),
B_TRANSLATE("OK"),
NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, 'r');
if (alert->Go())
return false;
removeExisting = true;
}
// TODO:
// use model-flavor specific virtuals for all of these special
// renamings
status_t result;
if (fModel->IsVolume()) {
BVolume volume(fModel->NodeRef()->device);
result = volume.InitCheck();
if (result == B_OK) {
RenameVolumeUndo undo(volume, text);
result = volume.SetName(text);
if (result != B_OK)
undo.Remove();
}
} else {
if (fModel->IsQuery()) {
BModelWriteOpener opener(fModel);
ASSERT(fModel->Node());
MoreOptionsStruct::SetQueryTemporary(fModel->Node(), false);
}
RenameUndo undo(entry, text);
result = entry.Rename(text, removeExisting);
if (result != B_OK)
undo.Remove();
}
return result == B_OK;
}
示例2:
int32_t
PDirectoryContains(void *pobject, void *in, void *out, void *extraData)
{
if (!pobject || !in || !out)
return B_ERROR;
PDirectory *parent = static_cast<PDirectory*>(pobject);
if (!parent)
return B_BAD_TYPE;
BDirectory *backend = (BDirectory*)parent->GetBackend();
PArgs *inArgs = static_cast<PArgs*>(in);
PArgs *outArgs = static_cast<PArgs*>(out);
BString path;
if (inArgs->FindString("path", &path) != B_OK)
return B_ERROR;
int32 type;
if (inArgs->FindInt32("type", &type) != B_OK)
return B_ERROR;
bool outValue1;
outValue1 = backend->Contains(path.String(), type);
outArgs->MakeEmpty();
return B_OK;
}
示例3: name
BEntry
MediaConverterApp::_CreateOutputFile(BDirectory directory,
entry_ref* ref, media_file_format* outputFormat)
{
BString name(ref->name);
// create output file name
int32 extIndex = name.FindLast('.');
if (extIndex != B_ERROR)
name.Truncate(extIndex + 1);
else
name.Append(".");
name.Append(outputFormat->file_extension);
BEntry inEntry(ref);
BEntry outEntry;
if (inEntry.InitCheck() == B_OK) {
// ensure that output name is unique
int32 len = name.Length();
int32 i = 1;
while (directory.Contains(name.String())) {
name.Truncate(len);
name << " " << i;
i++;
}
outEntry.SetTo(&directory, name.String());
}
return outEntry;
}
示例4: OpenWorksheet
PDoc* PApp::OpenWorksheet()
{
try
{
if (!gPrefsDir.Contains("Worksheet", B_FILE_NODE | B_SYMLINK_NODE))
{
BFile file;
gPrefsDir.CreateFile("Worksheet", &file);
}
BEntry w;
entry_ref wr;
FailOSErr(gPrefsDir.FindEntry("Worksheet", &w, true));
FailOSErr(w.GetRef(&wr));
OpenWindow(wr);
PDoc *d = dynamic_cast<PDoc*>(CDoc::FindDoc(wr));
if (d)
d->MakeWorksheet();
return d;
}
catch (HErr& e)
{
e.DoError();
}
return NULL;
} /* PApp::OpenWorksheet */
示例5:
status_t
GetSettingsDir(BDirectory &dir, BPath &path)
{
//BPath path;
status_t err;
// TODO: build list from text files
err = find_directory(B_USER_SETTINGS_DIRECTORY, &path, true);
if (err < B_OK)
return err;
dir.SetTo(path.Path());
if (!dir.Contains("pe"))
dir.CreateDirectory("pe", NULL);
path.Append("pe");
dir.SetTo(path.Path());
if (!dir.Contains("HeaderTemplates"))
dir.CreateDirectory("HeaderTemplates", NULL);
path.Append("HeaderTemplates");
dir.SetTo(path.Path());
return B_OK;
}
示例6: entry
bool
Feeder::Excluded(entry_ref *ref)
{
BEntry entry(ref) ;
entry_ref* excludeRef ;
BDirectory excludeDirectory ;
BPath path ;
for (int i = 0 ; (excludeRef = (entry_ref*)fExcludeList.ItemAt(i)) != NULL ; i++) {
excludeDirectory.SetTo(excludeRef) ;
if (excludeDirectory.Contains(&entry))
return true ;
}
return false ;
}
示例7: entry
void
DataTranslationsApplication::RefsReceived(BMessage* message)
{
BTranslatorRoster* roster = BTranslatorRoster::Default();
BPath path;
status_t status = find_directory(B_USER_ADDONS_DIRECTORY, &path, true);
if (status != B_OK) {
_InstallError("translator", status);
return;
}
BDirectory target;
status = target.SetTo(path.Path());
if (status == B_OK) {
if (!target.Contains("Translators"))
status = target.CreateDirectory("Translators", &target);
else
status = target.SetTo(&target, "Translators");
}
if (status != B_OK) {
_InstallError("translator", status);
return;
}
int32 i = 0;
entry_ref ref;
while (message->FindRef("refs", i++, &ref) == B_OK) {
if (!roster->IsTranslator(&ref)) {
_NoTranslatorError(ref.name);
continue;
}
BEntry entry(&ref, true);
status = entry.InitCheck();
if (status != B_OK) {
_InstallError(ref.name, status);
continue;
}
if (target.Contains(ref.name)) {
BString string(
B_TRANSLATE("An item named '%name' already exists in the "
"Translators folder! Shall the existing translator be "
"overwritten?"));
string.ReplaceAll("%name", ref.name);
BAlert* alert = new BAlert(B_TRANSLATE("DataTranslations - Note"),
string.String(), B_TRANSLATE("Cancel"),
B_TRANSLATE("Overwrite"));
alert->SetShortcut(0, B_ESCAPE);
if (alert->Go() != 1)
continue;
// the original file will be replaced
}
// find out whether we need to copy it or not
status = _Install(target, entry);
if (status == B_OK) {
BAlert* alert = new BAlert(B_TRANSLATE("DataTranslations - Note"),
B_TRANSLATE("The new translator has been installed "
"successfully."), B_TRANSLATE("OK"));
alert->Go(NULL);
} else
_InstallError(ref.name, status);
}
}
示例8: FindAndOpen
void PApp::FindAndOpen(const char *file, const char* fromSource)
{
char *bi = NULL;
bool found = false;
try
{
BEntry e;
entry_ref doc;
BDirectory d;
if (!found && fromSource)
{
BPath path;
entry_ref eref;
if (get_ref_for_path(fromSource, &eref) == B_OK) {
vector<BString> inclPathVect;
if (!ProjectRoster->GetIncludePathsForFile(&eref, inclPathVect))
ProjectRoster->GetAllIncludePaths(inclPathVect);
for(uint32 i=0; !found && i<inclPathVect.size(); ++i)
{
if (path.SetTo(inclPathVect[i].String(), file) != B_OK)
continue;
if (e.SetTo(path.Path(), true) != B_OK)
continue;
if (e.Exists() && e.IsFile()) {
FailOSErr(e.GetRef(&doc));
found = true;
}
}
}
}
if (!found && gPrefs->GetPrefInt(prf_I_BeIncludes))
{
bi = strdup(getenv("BEINCLUDES"));
char *ip = bi;
char *p = ip;
while (p && !found)
{
char *pe = strchr(p, ';');
if (pe) *pe = 0;
FailOSErr(d.SetTo(p));
if (d.Contains(file, B_FILE_NODE | B_SYMLINK_NODE))
{
FailOSErr(d.FindEntry(file, &e, true));
if (!e.IsFile()) THROW((0));
FailOSErr(e.GetRef(&doc));
found = true;
}
p = (pe && pe[1]) ? pe + 1 : NULL;
}
}
if (!found)
{
const char *p;
int i = 0;
while ((p = gPrefs->GetIxPrefString(prf_X_IncludePath, i++))!= NULL && !found)
{
if (e.SetTo(p) != B_OK || !e.Exists())
continue;
FailOSErr(d.SetTo(p));
if (d.Contains(file, B_FILE_NODE | B_SYMLINK_NODE))
{
FailOSErr(d.FindEntry(file, &e, true));
if (!e.IsFile()) THROW((0));
FailOSErr(e.GetRef(&doc));
found = true;
}
}
}
if (found)
OpenWindow(doc);
else
beep();
}
catch (HErr& e)
{
beep();
}
if (bi)
free(bi);
} // PApp::FindAndOpen
示例9: entry
PApp::PApp()
: BApplication("application/x-vnd.dw-PalEdit")
{
try
{
try
{
BPath settings;
FailOSErr(find_directory(B_USER_SETTINGS_DIRECTORY, &settings, true));
BDirectory e;
FailOSErrMsg(e.SetTo(settings.Path()), "~/config/settings directory not found ?!?!?");
if (!e.Contains("PalEdit", B_DIRECTORY_NODE))
FailOSErr(e.CreateDirectory("PalEdit", &gPrefsDir));
else
{
BEntry d;
FailOSErr(e.FindEntry("PalEdit", &d, B_DIRECTORY_NODE));
FailOSErr(gPrefsDir.SetTo(&d));
}
}
catch (HErr& e)
{
e.DoError();
}
gPrefs = new HPreferences("PalEdit/settings");
gPrefs->ReadPrefFile();
app_info ai;
GetAppInfo(&ai);
BEntry entry(&ai.ref);
FailOSErr(gAppFile.SetTo(&entry, B_READ_ONLY));
BPath appName;
FailOSErr(entry.GetPath(&appName));
BPath dir;
FailOSErr(appName.GetParent(&dir));
FailOSErr(gAppDir.SetTo(dir.Path()));
fOpenPanel = new BFilePanel();
FailNil(fOpenPanel);
entry_ref cwd_ref;
fOpenPanel->GetPanelDirectory(&cwd_ref);
FailOSErr(gCWD.SetTo(&cwd_ref));
PDoc::LoadAddOns();
InitUTFTables();
SetColor(kColorLow, prf_C_Low, 0xff, 0xff, 0xff);
SetColor(kColorText, prf_C_Text, 0x00, 0x00, 0x00);
SetColor(kColorSelection, prf_C_Selection, 0xd1, 0xd1, 0xff);
SetColor(kColorMark, prf_C_Mark, 0x00, 0x00, 0xff);
SetColor(kColorKeyword1, prf_C_Keyword1, 0x00, 0x00, 0xff);
SetColor(kColorKeyword2, prf_C_Keyword2, 0x00, 0x00, 0xff);
SetColor(kColorComment1, prf_C_Comment1, 0x1e, 0x93, 0x1e);
SetColor(kColorComment2, prf_C_Comment2, 0x1e, 0x93, 0x1e);
SetColor(kColorString1, prf_C_String1, 0x7e, 0x7e, 0x7e);
SetColor(kColorString2, prf_C_String2, 0x7e, 0x7e, 0x7e);
SetColor(kColorNumber1, prf_C_Number1, 0x85, 0x0a, 0x48);
SetColor(kColorNumber2, prf_C_Number2, 0x85, 0x0a, 0x48);
SetColor(kColorOperator1, prf_C_Operator1, 0x00, 0x00, 0x00);
SetColor(kColorOperator2, prf_C_Operator2, 0x00, 0x00, 0x00);
SetColor(kColorSeparator1, prf_C_Separator1, 0x00, 0x00, 0x00);
SetColor(kColorSeparator2, prf_C_Separator2, 0x00, 0x00, 0x00);
SetColor(kColorPreprocessor1, prf_C_Preprocessor1, 0x00, 0x00, 0xff);
SetColor(kColorPreprocessor2, prf_C_Preprocessor2, 0x00, 0x00, 0xff);
SetColor(kColorError1, prf_C_Error1, 0xff, 0x00, 0x00);
SetColor(kColorError2, prf_C_Error2, 0xff, 0x00, 0x00);
SetColor(kColorIdentifierSystem,prf_C_IdentifierSystem, 0x39, 0x79, 0x79);
SetColor(kColorCharConst, prf_C_CharConst, 0x7e, 0x7e, 0x7e);
SetColor(kColorIdentifierUser, prf_C_IdentifierUser, 0x00, 0x00, 0x00);
SetColor(kColorTag, prf_C_Tag, 0x88, 0x88, 0x88);
SetColor(kColorAttribute, prf_C_Attribute, 0xff, 0x00, 0x00);
SetColor(kColorUserSet1, prf_C_UserSet1, 0x00, 0x00, 0x00);
SetColor(kColorUserSet2, prf_C_UserSet2, 0x00, 0x00, 0x00);
SetColor(kColorUserSet3, prf_C_UserSet3, 0x00, 0x00, 0x00);
SetColor(kColorUserSet4, prf_C_UserSet4, 0x00, 0x00, 0x00);
SetColor(kColorInvisibles, prf_C_Invisibles, 0xC8, 0x64, 0x64);
DefineInvColors(gColor[kColorSelection]);
gAutoIndent = gPrefs->GetPrefInt(prf_I_AutoIndent, 1);
gSyntaxColoring = gPrefs->GetPrefInt(prf_I_SyntaxColoring, 1);
gSpacesPerTab = gPrefs->GetPrefInt(prf_I_SpacesPerTab, 4);
gBalance = gPrefs->GetPrefInt(prf_I_BalanceWhileTyping, 1);
gBlockCursor = gPrefs->GetPrefInt(prf_I_BlockCursor, 0);
gFlashCursor = gPrefs->GetPrefInt(prf_I_FlashCursor, 1);
gSmartBrace = gPrefs->GetPrefInt(prf_I_SmartBraces, 1);
gPopupIncludes = gPrefs->GetPrefInt(prf_I_ShowIncludes, 1);
gPopupProtos = gPrefs->GetPrefInt(prf_I_ShowPrototypes, 1);
gPopupFuncs = gPrefs->GetPrefInt(prf_I_ShowTypes, 1);
gPopupSorted = gPrefs->GetPrefInt(prf_I_SortPopup, 0);
gRedirectStdErr = gPrefs->GetPrefInt(prf_I_RedirectStdErr, 1);
gUseWorksheet = gPrefs->GetPrefInt(prf_I_Worksheet, 0);
//.........这里部分代码省略.........