本文整理汇总了C++中BEntry::MoveTo方法的典型用法代码示例。如果您正苦于以下问题:C++ BEntry::MoveTo方法的具体用法?C++ BEntry::MoveTo怎么用?C++ BEntry::MoveTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BEntry
的用法示例。
在下文中一共展示了BEntry::MoveTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MessageReceived
void ViewFileList::MessageReceived(BMessage *e) {
switch (e->what) {
case B_MOUSE_WHEEL_CHANGED: Window()->PostMessage(e); break;
case B_SIMPLE_DATA: {
if (e->FindString("source") != NULL)
if (strcmp(e->FindString("source"),"Peek")==0 ) break;
// moving or copying? hmm..
status_t stattoo;
entry_ref dropped;
bool overwriteAll = false;
BEntry *heyMan;
char path[B_PATH_NAME_LENGTH];
setup->CurrentPath(path);
BDirectory *heyDude = new BDirectory( path );
int32 i = 0;
while (e->FindRef("refs",i++,&dropped) == B_OK) {
heyMan = new BEntry(&dropped);
stattoo = heyMan->MoveTo(heyDude, NULL, overwriteAll);
if (stattoo == B_FILE_EXISTS) { // exists => overwrite?
char overwrite[255];
strcpy(overwrite,dropped.name);
strcat(overwrite,words->Return(L_REPLACE_FILE));
stattoo = B_OK;
int32 ok = ((new BAlert("overWrite",overwrite,words->Return(L_YES_TO_ALL),words->Return(L_YES),words->Return(L_NO)))->Go());
if (ok == 0) { overwriteAll = true; ok = 1;}
if (ok == 1) {
stattoo = heyMan->MoveTo(heyDude, NULL, true);
}
}
if (stattoo != B_OK) { // some error!!!
((new BAlert("darnnit",words->Return(L_ERROR_COPYING),words->Return(L_OK)))->Go());
delete heyMan;
break;
}
delete heyMan; // delete it.
}
delete heyDude;
break;
}
default: BListView::MessageReceived(e); break;
}
}
示例2:
/*!
Installs the given entry in the target directory either by moving
or copying the entry.
*/
status_t
DataTranslationsApplication::_Install(BDirectory& target, BEntry& entry)
{
// Find out whether we need to copy it
status_t status = entry.MoveTo(&target, NULL, true);
if (status == B_OK)
return B_OK;
// we need to copy the file
// TODO!
return B_ERROR;
}
示例3: node
//.........这里部分代码省略.........
entry_ref *fileref = FindItem();
be_roster->Launch(fileref);
break;
}
case MNU_LEFT_TRACKER_MSG:
{
BString sysstring;
BEntry direntry;
BPath dirpath;
dir.GetEntry(&direntry);
direntry.GetPath(&dirpath);
sysstring << "/system/Tracker ";
sysstring << dirpath.Path();
//(new BAlert("Niue", sysstring.String(), "Ok", 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
system(sysstring.String());
break;
}
case MNU_LEFT_TRASH_MSG:
{
//(new BAlert("Niue", "trash it", "Ok", 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
entry_ref *fileref = FindItem();
BEntry fileentry;
BDirectory trashdir;
BPath trashpath;
find_directory(B_TRASH_DIRECTORY, &trashpath, false);
fileentry.SetTo(fileref);
trashdir.SetTo(trashpath.Path());
fileentry.MoveTo(&trashdir, 0, true);
break;
}
case MNU_LEFT_DUPLICATE_MSG:
{
BString duplistring;
BEntry duplientry;
BPath duplipath;
entry_ref *fileref = FindItem();
duplientry.SetTo(fileref);
duplientry.GetPath(&duplipath);
duplistring << "cp ";
duplistring << duplipath.Path();
duplistring << " ";
duplistring << duplipath.Path();
duplistring << "_copy";
//(new BAlert("Niue", duplistring.String(), "Ok", 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
system(duplistring.String());
break;
}
case MNU_LEFT_INFO_MSG:
{
//get item, create vars
entry_ref *fileref = FindItem();
BEntry fileentry;
fileentry.SetTo(fileref, true);
//name
char name[B_FILE_NAME_LENGTH];
fileentry.GetName(name);
示例4: DistributeEmail
//.........这里部分代码省略.........
//setup a temp file to store the modified og msg
std::stringstream epochsecs;
epochsecs << real_time_clock(); //secs now since unix epoch
int filenamecounterInt=0; //will be incremented until we get a unique filename string
bool nonuniquefilename=true;
BEntry tempFileBEntry;
std::string tempFilePath;
BFile* tempFileBFile = new BFile();
do
{
filenamecounterInt++;
std::stringstream filenamecounter;
filenamecounter << filenamecounterInt;
tempFilePath=fApp->GetTempDirPath()+fListICAddress+"--"+epochsecs.str()+filenamecounter.str();
//test if tempFilePath already exists
tempFileBEntry.SetTo(tempFilePath.c_str());
status_t tempFileResult=tempFileBFile->SetTo(&tempFileBEntry,B_READ_WRITE|B_FAIL_IF_EXISTS|B_CREATE_FILE); //fails if already exists
if (tempFileResult==B_FILE_EXISTS)
{
nonuniquefilename=true;
}
else if (tempFileResult==B_NO_ERROR)
{
nonuniquefilename=false;
}
else
{
//error
LogError("ERROR: Could not create temp file to store outgoing email");
return false;
}
}while(nonuniquefilename);
//Write modified msg into temp file
ICMail->WriteToFile(tempFileBFile);
//store senders addr so we can log it later
std::string sender="";
//Send out modified msg in temp file to all recipients
for (int x=0; x< recipients.size(); x++)
{
std::string recipient=recipients[x];
BEmailMessage* ogmail;
ogmail= new BEmailMessage(tempFileBFile);
ogmail->SetTo(recipient.c_str());
sender=std::string(ogmail->From());
//1st version of send indicates whether to change the From: field to the specified account (requires modified mailkit)
ogmail->SendViaAccountWithFromPreset(fListOGEnvelopeAddressFromAddress.c_str());
//ogmail->SendViaAccount(fListOGEnvelopeAddressFromAddress.c_str());
ogmail->Send(true);
delete ogmail;
}
tempFileBFile->Unset(); //close file
delete tempFileBFile; //delete obj
//archive msg if needed
bool archived=false;
if (fArchivePath!="")
{
BDirectory dir;
if ( dir.SetTo(fArchivePath.c_str()) !=B_OK )
{
LogError("ERROR: Could not archive message. Check archive folder exists and is writable");
}
else
{
if ( tempFileBEntry.MoveTo(&dir) !=B_NO_ERROR)
{
LogError("ERROR: Could not archive message. Check archive folder exists and is writable");
}
else
{
archived=true;
}
}
}
if (archived==false)
{
//if archived then the file was moved so we dont need to delete the original
tempFileBEntry.Remove();//remove file from filesystem
}
stringstream numRecipients;
numRecipients << recipients.size();
if ( (fLogSuccesses) && (recipients.size()>0) )
{
//if we recipients.size() was 0 sender var is null str as its set in the distribution loop
LogError("INFO: Successfully distributed an email to "+numRecipients.str()+" recipients from "+sender);
}
return true;
}