本文整理汇总了C++中CMyComPtr::SetFolder方法的典型用法代码示例。如果您正苦于以下问题:C++ CMyComPtr::SetFolder方法的具体用法?C++ CMyComPtr::SetFolder怎么用?C++ CMyComPtr::SetFolder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMyComPtr
的用法示例。
在下文中一共展示了CMyComPtr::SetFolder方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DeleteFiles
int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems, int opMode)
{
if (numItems == 0)
return FALSE;
/*
if (!m_ArchiverInfo.UpdateEnabled)
{
g_StartupInfo.ShowMessage(NMessageID::kUpdateNotSupportedForThisArchive);
return FALSE;
}
*/
if ((opMode & OPM_SILENT) == 0)
{
const char *msgItems[]=
{
g_StartupInfo.GetMsgString(NMessageID::kDeleteTitle),
g_StartupInfo.GetMsgString(NMessageID::kDeleteFiles),
g_StartupInfo.GetMsgString(NMessageID::kDeleteDelete),
g_StartupInfo.GetMsgString(NMessageID::kDeleteCancel)
};
char msg[1024];
if (numItems == 1)
{
sprintf(msg, g_StartupInfo.GetMsgString(NMessageID::kDeleteFile), panelItems[0].FindData.cFileName);
msgItems[1] = msg;
}
else if (numItems > 1)
{
sprintf(msg, g_StartupInfo.GetMsgString(NMessageID::kDeleteNumberOfFiles),
numItems);
msgItems[1] = msg;
}
if (g_StartupInfo.ShowMessage(FMSG_WARNING, NULL, msgItems,
sizeof(msgItems) / sizeof(msgItems[0]), 2) != 0)
return (FALSE);
}
CScreenRestorer screenRestorer;
CProgressBox progressBox;
CProgressBox *progressBoxPointer = NULL;
if ((opMode & OPM_SILENT) == 0 && (opMode & OPM_FIND ) == 0)
{
screenRestorer.Save();
progressBoxPointer = &progressBox;
progressBox.Init(
// g_StartupInfo.GetMsgString(NMessageID::kWaitTitle),
g_StartupInfo.GetMsgString(NMessageID::kDeleting), 48);
}
CWorkDirTempFile tempFile;
if (tempFile.CreateTempFile(m_FileName) != S_OK)
return FALSE;
CRecordVector<UINT32> indices;
indices.Reserve(numItems);
int i;
for (i = 0; i < numItems; i++)
indices.Add((UINT32)panelItems[i].UserData);
////////////////////////////
// Save _folder;
UStringVector pathVector;
GetPathParts(pathVector);
CMyComPtr<IOutFolderArchive> outArchive;
HRESULT result = m_ArchiveHandler.QueryInterface(IID_IOutFolderArchive, &outArchive);
if (result != S_OK)
{
g_StartupInfo.ShowMessage(NMessageID::kUpdateNotSupportedForThisArchive);
return FALSE;
}
outArchive->SetFolder(_folder);
CUpdateCallback100Imp *updateCallbackSpec = new CUpdateCallback100Imp;
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec);
updateCallbackSpec->Init(/* m_ArchiveHandler, */ progressBoxPointer);
result = outArchive->DeleteItems(tempFile.OutStream, &indices.Front(), indices.Size(), updateCallback);
updateCallback.Release();
outArchive.Release();
if (result == S_OK)
{
result = AfterUpdate(tempFile, pathVector);
}
if (result != S_OK)
{
ShowErrorMessage(result);
return FALSE;
}
GetCurrentDir();
return TRUE;
}
示例2: PutFiles
//.........这里部分代码省略.........
throw 51751;
compressionInfo.Save();
CWorkDirTempFile tempFile;;
if (tempFile.CreateTempFile(m_FileName) != S_OK)
return NFileOperationReturnCode::kError;
/*
CSysStringVector fileNames;
for (int i = 0; i < numItems; i++)
{
const PluginPanelItem &panelItem = panelItems[i];
CSysString fullName;
if (!MyGetFullPathName(panelItem.FindData.cFileName, fullName))
return NFileOperationReturnCode::kError;
fileNames.Add(fullName);
}
*/
CScreenRestorer screenRestorer;
CProgressBox progressBox;
CProgressBox *progressBoxPointer = NULL;
if ((opMode & OPM_SILENT) == 0 && (opMode & OPM_FIND ) == 0)
{
screenRestorer.Save();
progressBoxPointer = &progressBox;
progressBox.Init(
// g_StartupInfo.GetMsgString(NMessageID::kWaitTitle),
g_StartupInfo.GetMsgString(NMessageID::kUpdating), 48);
}
UStringVector pathVector;
GetPathParts(pathVector);
UStringVector fileNames;
fileNames.Reserve(numItems);
for (i = 0; i < numItems; i++)
fileNames.Add(MultiByteToUnicodeString(panelItems[i].FindData.cFileName, CP_OEMCP));
CRecordVector<const wchar_t *> fileNamePointers;
fileNamePointers.Reserve(numItems);
for (i = 0; i < numItems; i++)
fileNamePointers.Add(fileNames[i]);
CMyComPtr<IOutFolderArchive> outArchive;
HRESULT result = m_ArchiveHandler.QueryInterface(IID_IOutFolderArchive, &outArchive);
if (result != S_OK)
{
g_StartupInfo.ShowMessage(NMessageID::kUpdateNotSupportedForThisArchive);
return NFileOperationReturnCode::kError;
}
outArchive->SetFolder(_folder);
outArchive->SetFiles(L"", &fileNamePointers.Front(), fileNamePointers.Size());
BYTE actionSetByte[NUpdateArchive::NPairState::kNumValues];
for (i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
actionSetByte[i] = (BYTE)actionSet->StateActions[i];
CUpdateCallback100Imp *updateCallbackSpec = new CUpdateCallback100Imp;
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec );
updateCallbackSpec->Init(/* m_ArchiveHandler, */ progressBoxPointer);
if (SetOutProperties(outArchive, compressionInfo.Level) != S_OK)
return NFileOperationReturnCode::kError;
result = outArchive->DoOperation2(tempFile.OutStream, actionSetByte, NULL, updateCallback);
updateCallback.Release();
outArchive.Release();
if (result == S_OK)
{
result = AfterUpdate(tempFile, pathVector);
}
if (result != S_OK)
{
ShowErrorMessage(result);
return NFileOperationReturnCode::kError;
}
/*
if (moveMode != 0)
{
for (int i = 0; i < numItems; i++)
{
const PluginPanelItem &pluginPanelItem = panelItems[i];
bool result;
if (NFile::NFind::NAttributes::IsDir(pluginPanelItem.FindData.dwFileAttributes))
result = NFile::NDirectory::RemoveDirectoryWithSubItems(pluginPanelItem.FindData.cFileName);
else
result = NFile::NDirectory::DeleteFileAlways(pluginPanelItem.FindData.cFileName);
if (!result)
return NFileOperationReturnCode::kError;
}
}
*/
return NFileOperationReturnCode::kSuccess;
}
示例3: DeleteFiles
int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems,
int opMode)
{
if (numItems == 0)
return FALSE;
/*
if (!m_ArchiverInfo.UpdateEnabled)
{
g_StartupInfo.ShowMessage(NMessageID::kUpdateNotSupportedForThisArchive);
return FALSE;
}
*/
if ((opMode & OPM_SILENT) == 0)
{
const char *msgItems[]=
{
g_StartupInfo.GetMsgString(NMessageID::kDeleteTitle),
g_StartupInfo.GetMsgString(NMessageID::kDeleteFiles),
g_StartupInfo.GetMsgString(NMessageID::kDeleteDelete),
g_StartupInfo.GetMsgString(NMessageID::kDeleteCancel)
};
char msg[1024];
if (numItems == 1)
{
sprintf(msg, g_StartupInfo.GetMsgString(NMessageID::kDeleteFile),
panelItems[0].FindData.cFileName);
msgItems[1] = msg;
}
else if (numItems > 1)
{
sprintf(msg, g_StartupInfo.GetMsgString(NMessageID::kDeleteNumberOfFiles),
numItems);
msgItems[1] = msg;
}
if (g_StartupInfo.ShowMessage(FMSG_WARNING, NULL, msgItems,
sizeof(msgItems) / sizeof(msgItems[0]), 2) != 0)
return (FALSE);
}
CScreenRestorer screenRestorer;
CProgressBox progressBox;
CProgressBox *progressBoxPointer = NULL;
if ((opMode & OPM_SILENT) == 0 && (opMode & OPM_FIND ) == 0)
{
screenRestorer.Save();
progressBoxPointer = &progressBox;
progressBox.Init(
// g_StartupInfo.GetMsgString(NMessageID::kWaitTitle),
g_StartupInfo.GetMsgString(NMessageID::kDeleting), 48);
}
NWorkDir::CInfo workDirInfo;
ReadWorkDirInfo(workDirInfo);
UString workDir = GetWorkDir(workDirInfo, m_FileName);
CreateComplexDirectory(workDir);
CTempFileW tempFile;
UString tempFileName;
if (tempFile.Create(workDir, kTempArchivePrefix, tempFileName) == 0)
return FALSE;
CRecordVector<UINT32> indices;
indices.Reserve(numItems);
int i;
for(i = 0; i < numItems; i++)
indices.Add(panelItems[i].UserData);
////////////////////////////
// Save _folder;
UStringVector pathVector;
GetPathParts(pathVector);
CMyComPtr<IOutFolderArchive> outArchive;
HRESULT result = m_ArchiveHandler.QueryInterface(
IID_IOutFolderArchive, &outArchive);
if(result != S_OK)
{
g_StartupInfo.ShowMessage(NMessageID::kUpdateNotSupportedForThisArchive);
return FALSE;
}
outArchive->SetFolder(_folder);
CUpdateCallback100Imp *updateCallbackSpec = new CUpdateCallback100Imp;
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec );
updateCallbackSpec->Init(/* m_ArchiveHandler, */ &progressBox);
result = outArchive->DeleteItems(
tempFileName,
&indices.Front(), indices.Size(),
updateCallback);
updateCallback.Release();
outArchive.Release();
if (result != S_OK)
//.........这里部分代码省略.........
示例4: CompressFiles
//.........这里部分代码省略.........
CProgressBox progressBox;
CProgressBox *progressBoxPointer = NULL;
screenRestorer.Save();
progressBoxPointer = &progressBox;
progressBox.Init(
// g_StartupInfo.GetMsgString(NMessageID::kWaitTitle),
g_StartupInfo.GetMsgString(NMessageID::kUpdating), 48);
NFind::CFileInfo fileInfo;
CMyComPtr<IOutFolderArchive> outArchive;
CMyComPtr<IInFolderArchive> archiveHandler;
if (fileInfo.Find(fullArchiveName))
{
if (fileInfo.IsDir())
throw "There is Directory with such name";
CAgent *agentSpec = new CAgent;
archiveHandler = agentSpec;
// CLSID realClassID;
CMyComBSTR archiveType;
RINOK(agentSpec->Open(NULL,
GetUnicodeString(fullArchiveName, CP_OEMCP), UString(),
// &realClassID,
&archiveType,
NULL));
if (archiverInfoFinal.Name.CompareNoCase((const wchar_t *)archiveType) != 0)
throw "Type of existing archive differs from specified type";
HRESULT result = archiveHandler.QueryInterface(
IID_IOutFolderArchive, &outArchive);
if (result != S_OK)
{
g_StartupInfo.ShowMessage(NMessageID::kUpdateNotSupportedForThisArchive);
return E_FAIL;
}
}
else
{
// HRESULT result = outArchive.CoCreateInstance(classID);
CAgent *agentSpec = new CAgent;
outArchive = agentSpec;
/*
HRESULT result = outArchive.CoCreateInstance(CLSID_CAgentArchiveHandler);
if (result != S_OK)
{
g_StartupInfo.ShowMessage(NMessageID::kUpdateNotSupportedForThisArchive);
return E_FAIL;
}
*/
}
CRecordVector<const wchar_t *> fileNamePointers;
fileNamePointers.Reserve(fileNames.Size());
for (i = 0; i < fileNames.Size(); i++)
fileNamePointers.Add(fileNames[i]);
outArchive->SetFolder(NULL);
outArchive->SetFiles(L"", &fileNamePointers.Front(), fileNamePointers.Size());
BYTE actionSetByte[NUpdateArchive::NPairState::kNumValues];
for (i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
actionSetByte[i] = (BYTE)actionSet->StateActions[i];
CUpdateCallback100Imp *updateCallbackSpec = new CUpdateCallback100Imp;
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec );
updateCallbackSpec->Init(/* archiveHandler, */ progressBoxPointer);
RINOK(SetOutProperties(outArchive, compressionInfo.Level));
HRESULT result = outArchive->DoOperation(
codecs, archiverIndex,
tempFile.OutStream, actionSetByte,
NULL, updateCallback);
updateCallback.Release();
outArchive.Release();
if (result != S_OK)
{
ShowErrorMessage(result);
return result;
}
if (archiveHandler)
{
archiveHandler->Close();
}
if (!tempFile.MoveToOriginal(archiveHandler != NULL))
{
ShowLastErrorMessage();
return E_FAIL;
}
return S_OK;
}