While modernizing more NULL and BOOL situations, I encountered the following two comments in the
code ...
`// TODO: Convert to PLUGIN_MODE and fix compile error` and
`// TODO: Convert bMode to PLUGIN_MODE and fix compile errors`
* Values of type `PLUGIN_MODE` were being stored into `int` variables, often with a `b` prefix
(implying the variables were boolean in nature).
* And values themselves were sometimes `false`, or `1` although sometimes from the `PLUGIN_MODE`
enumeration.
* Value testing often assumed the values were boolean (i.e. zero or non-zero)
* I've changed all appropriate variables to type `PLUGIN_MODE` and used explicit values from the
enumeration in all related expressions.
* I've also taken the opportunity to modernize all member variables in the `PluginForFile` and
`PackingInfo` classes, by adding an explicit `m_` prefix
--HG--
branch : stable
InitNew(); // leave crystal editor in valid, empty state
return FileLoadResult::FRESULT_ERROR_UNPACK;
}
- m_unpackerSubcode = infoUnpacker->subcode;
+ m_unpackerSubcode = infoUnpacker->m_subcode;
// we use the same unpacker for both files, so it must be defined after first file
- ASSERT(infoUnpacker->bToBeScanned != PLUGIN_AUTO);
+ ASSERT(infoUnpacker->m_PluginOrPredifferMode != PLUGIN_AUTO);
// we will load the transformed file
LPCTSTR pszFileName = sFileName.c_str();
if (def && def->encoding != -1)
m_nSourceEncoding = def->encoding;
- UniFile *pufile = infoUnpacker->pufile;
- if (pufile == 0)
+ UniFile *pufile = infoUnpacker->m_pufile;
+ if (pufile == nullptr)
pufile = new UniMemFile;
// Now we only use the UniFile interface
}
else
{
- if (infoUnpacker->pluginName.length() > 0)
+ if (infoUnpacker->m_PluginName.length() > 0)
{
// re-detect codepage
int iGuessEncodingType = GetOptionsMgr()->GetInt(OPT_CP_DETECT);
if (nCrlfStyle == CRLF_STYLE_AUTOMATIC &&
!GetOptionsMgr()->GetBool(OPT_ALLOW_MIXED_EOL) ||
- infoUnpacker && infoUnpacker->disallowMixedEOL)
+ infoUnpacker!=nullptr && infoUnpacker->m_bDisallowMixedEOL)
{
// get the default nCrlfStyle of the CDiffTextBuffer
nCrlfStyle = GetCRLFMode();
ASSERT(infoUnpacker != nullptr);
// repack the file here, overwrite the temporary file we did save in
String csTempFileName = sIntermediateFilename;
- infoUnpacker->subcode = m_unpackerSubcode;
+ infoUnpacker->m_subcode = m_unpackerSubcode;
if (!FileTransform::Packing(csTempFileName, *infoUnpacker))
{
try
String sError = strutils::format(
_T("An error occurred while prediffing the file '%s' with the plugin '%s'. The prediffing is not applied any more."),
strFileTemp[file].c_str(),
- m_infoPrediffer->pluginName.c_str());
+ m_infoPrediffer->m_PluginName.c_str());
AppErrorMessageBox(sError);
// don't use any more this prediffer
- m_infoPrediffer->bToBeScanned = false;
- m_infoPrediffer->pluginName.erase();
+ m_infoPrediffer->m_PluginOrPredifferMode = PLUGIN_MANUAL;
+ m_infoPrediffer->m_PluginName.erase();
}
// We use the same plugin for both files, so it must be defined before
// second file
- assert(!m_infoPrediffer->bToBeScanned);
+ assert(m_infoPrediffer->m_PluginOrPredifferMode == PLUGIN_MANUAL);
}
}
#include "paths.h"
#include "IntToIntMap.h"
#include <algorithm>
+#include "FileTransform.h"
struct DIFFITEM;
class CDiffContext;
* @brief Apply specified setting for prediffing to all selected items
*/
template<class InputIterator>
-void ApplyPluginPrediffSetting(const InputIterator& begin, const InputIterator& end, const CDiffContext& ctxt, int newsetting)
+void ApplyPluginPrediffSetting(const InputIterator& begin, const InputIterator& end, const CDiffContext& ctxt, PLUGIN_MODE newsetting)
{
// Unlike other group actions, here we don't build an action list
// to execute; we just apply this change directly
PackingInfo * unpacker;
PrediffingInfo * prediffer;
const_cast<CDiffContext&>(ctxt).FetchPluginInfos(filteredFilenames, &unpacker, &prediffer);
- if (prediffer->bToBeScanned == 1 || !prediffer->pluginName.empty())
+ if (prediffer->m_PluginOrPredifferMode == PLUGIN_AUTO || !prediffer->m_PluginName.empty())
nPredifferYes ++;
else
nPredifferNo ++;
namespace FileTransform
{
-int g_bUnpackerMode = PLUGIN_MANUAL;
-int g_bPredifferMode = PLUGIN_MANUAL;
+PLUGIN_MODE g_UnpackerMode = PLUGIN_MANUAL;
+PLUGIN_MODE g_PredifferMode = PLUGIN_MANUAL;
bool Packing(String & filepath, PackingInfo handler)
{
// no handler : return true
- if (handler.pluginName.empty())
+ if (handler.m_PluginName.empty())
return true;
storageForPlugins bufferData;
// control value
bool bHandled = false;
- PluginInfo * plugin = CAllThreadsScripts::GetActiveSet()->GetPluginByName(L"FILE_PACK_UNPACK", handler.pluginName);
+ PluginInfo * plugin = CAllThreadsScripts::GetActiveSet()->GetPluginByName(L"FILE_PACK_UNPACK", handler.m_PluginName);
if (plugin == nullptr)
- plugin = CAllThreadsScripts::GetActiveSet()->GetPluginByName(L"FILE_FOLDER_PACK_UNPACK", handler.pluginName);
+ plugin = CAllThreadsScripts::GetActiveSet()->GetPluginByName(L"FILE_FOLDER_PACK_UNPACK", handler.m_PluginName);
if (plugin == nullptr)
- plugin = CAllThreadsScripts::GetActiveSet()->GetPluginByName(L"BUFFER_PACK_UNPACK", handler.pluginName);
+ plugin = CAllThreadsScripts::GetActiveSet()->GetPluginByName(L"BUFFER_PACK_UNPACK", handler.m_PluginName);
LPDISPATCH piScript = plugin->m_lpDispatch;
- if (handler.bWithFile)
+ if (handler.m_bWithFile)
{
// use a temporary dest name
String srcFileName = bufferData.GetDataFileAnsi(); // <-Call order is important
bHandled = plugin::InvokePackFile(srcFileName,
dstFileName,
bufferData.GetNChanged(),
- piScript, handler.subcode);
+ piScript, handler.m_subcode);
if (bHandled)
bufferData.ValidateNewFile();
}
{
bHandled = plugin::InvokePackBuffer(*bufferData.GetDataBufferAnsi(),
bufferData.GetNChanged(),
- piScript, handler.subcode);
+ piScript, handler.m_subcode);
if (bHandled)
bufferData.ValidateNewBuffer();
}
bool Unpacking(String & filepath, const PackingInfo * handler, int * handlerSubcode)
{
// no handler : return true
- if (handler == nullptr || handler->pluginName.empty())
+ if (handler == nullptr || handler->m_PluginName.empty())
return true;
storageForPlugins bufferData;
// control value
bool bHandled = false;
- PluginInfo * plugin = CAllThreadsScripts::GetActiveSet()->GetPluginByName(L"FILE_PACK_UNPACK", handler->pluginName);
+ PluginInfo * plugin = CAllThreadsScripts::GetActiveSet()->GetPluginByName(L"FILE_PACK_UNPACK", handler->m_PluginName);
if (plugin == nullptr)
- plugin = CAllThreadsScripts::GetActiveSet()->GetPluginByName(L"FILE_FOLDER_PACK_UNPACK", handler->pluginName);
+ plugin = CAllThreadsScripts::GetActiveSet()->GetPluginByName(L"FILE_FOLDER_PACK_UNPACK", handler->m_PluginName);
if (plugin == nullptr)
- plugin = CAllThreadsScripts::GetActiveSet()->GetPluginByName(L"BUFFER_PACK_UNPACK", handler->pluginName);
+ plugin = CAllThreadsScripts::GetActiveSet()->GetPluginByName(L"BUFFER_PACK_UNPACK", handler->m_PluginName);
if (plugin == nullptr)
return false;
LPDISPATCH piScript = plugin->m_lpDispatch;
- if (handler->bWithFile)
+ if (handler->m_bWithFile)
{
// use a temporary dest name
String srcFileName = bufferData.GetDataFileAnsi(); // <-Call order is important
bool Unpacking(String & filepath, const String& filteredText, PackingInfo * handler, int * handlerSubcode)
{
// PLUGIN_BUILTIN_XML : read source file through custom UniFile
- if (handler->bToBeScanned == PLUGIN_BUILTIN_XML)
+ if (handler->m_PluginOrPredifferMode == PLUGIN_BUILTIN_XML)
{
- handler->pufile = new UniMarkdownFile;
- handler->textType = _T("xml");
- handler->disallowMixedEOL = true;
- handler->pluginName.erase(); // Make FileTransform_Packing() a NOP
- // Leave bToBeScanned alone so above lines will continue to execute on
+ handler->m_pufile = new UniMarkdownFile;
+ handler->m_textType = _T("xml");
+ handler->m_bDisallowMixedEOL = true;
+ handler->m_PluginName.erase(); // Make FileTransform_Packing() a NOP
+ // Leave eToBeScanned alone so above lines will continue to execute on
// subsequent calls to this function
return true;
}
plugin = CAllThreadsScripts::GetActiveSet()->GetAutomaticPluginByFilter(L"FILE_FOLDER_PACK_UNPACK", filteredText);
if (plugin != nullptr)
{
- handler->pluginName = plugin->m_name;
- handler->bWithFile = true;
+ handler->m_PluginName = plugin->m_name;
+ handler->m_bWithFile = true;
// use a temporary dest name
String srcFileName = bufferData.GetDataFileAnsi(); // <-Call order is important
String dstFileName = bufferData.GetDestFileName(); // <-Call order is important
bHandled = plugin::InvokeUnpackFile(srcFileName,
dstFileName,
bufferData.GetNChanged(),
- plugin->m_lpDispatch, handler->subcode);
+ plugin->m_lpDispatch, handler->m_subcode);
if (bHandled)
bufferData.ValidateNewFile();
}
plugin = CAllThreadsScripts::GetActiveSet()->GetAutomaticPluginByFilter(L"BUFFER_PACK_UNPACK", filteredText);
if (plugin != nullptr)
{
- handler->pluginName = plugin->m_name;
- handler->bWithFile = false;
+ handler->m_PluginName = plugin->m_name;
+ handler->m_bWithFile = false;
bHandled = plugin::InvokeUnpackBuffer(*bufferData.GetDataBufferAnsi(),
bufferData.GetNChanged(),
- plugin->m_lpDispatch, handler->subcode);
+ plugin->m_lpDispatch, handler->m_subcode);
if (bHandled)
bufferData.ValidateNewBuffer();
}
if (!bHandled)
{
// we didn't find any unpacker, just hope it is normal Ansi/Unicode
- handler->pluginName = _T("");
- handler->subcode = 0;
+ handler->m_PluginName = _T("");
+ handler->m_subcode = 0;
bHandled = true;
}
// the handler is now defined
- handler->bToBeScanned = false;
+ handler->m_PluginOrPredifferMode = PLUGIN_MANUAL;
// assign the sucode
- *handlerSubcode = handler->subcode;
+ *handlerSubcode = handler->m_subcode;
// if the buffer changed, write it before leaving
bool bSuccess = true;
bool Unpacking(PackingInfo *handler, String& filepath, const String& filteredText)
{
- if (handler->bToBeScanned)
- return Unpacking(filepath, filteredText, handler, &handler->subcode);
+ if (handler->m_PluginOrPredifferMode != PLUGIN_MANUAL)
+ return Unpacking(filepath, filteredText, handler, &handler->m_subcode);
else
- return Unpacking(filepath, handler, &handler->subcode);
+ return Unpacking(filepath, handler, &handler->m_subcode);
}
////////////////////////////////////////////////////////////////////////////////
bool Prediffing(String & filepath, PrediffingInfo handler, bool bMayOverwrite)
{
// no handler : return true
- if (handler.pluginName.empty())
+ if (handler.m_PluginName.empty())
return true;
storageForPlugins bufferData;
// control value
bool bHandled = false;
- PluginInfo * plugin = CAllThreadsScripts::GetActiveSet()->GetPluginByName(L"FILE_PREDIFF", handler.pluginName);
+ PluginInfo * plugin = CAllThreadsScripts::GetActiveSet()->GetPluginByName(L"FILE_PREDIFF", handler.m_PluginName);
if (plugin == nullptr)
{
- plugin = CAllThreadsScripts::GetActiveSet()->GetPluginByName(L"BUFFER_PREDIFF", handler.pluginName);
+ plugin = CAllThreadsScripts::GetActiveSet()->GetPluginByName(L"BUFFER_PREDIFF", handler.m_PluginName);
if (plugin == nullptr)
return false;
}
LPDISPATCH piScript = plugin->m_lpDispatch;
- if (handler.bWithFile)
+ if (handler.m_bWithFile)
{
// use a temporary dest name
String srcFileName = bufferData.GetDataFileAnsi(); // <-Call order is important
PluginInfo * plugin = CAllThreadsScripts::GetActiveSet()->GetAutomaticPluginByFilter(L"FILE_PREDIFF", filteredText);
if (plugin != nullptr)
{
- handler->pluginName = plugin->m_name;
- handler->bWithFile = true;
+ handler->m_PluginName = plugin->m_name;
+ handler->m_bWithFile = true;
// use a temporary dest name
String srcFileName = bufferData.GetDataFileAnsi(); // <-Call order is important
String dstFileName = bufferData.GetDestFileName(); // <-Call order is important
plugin = CAllThreadsScripts::GetActiveSet()->GetAutomaticPluginByFilter(L"BUFFER_PREDIFF", filteredText);
if (plugin != nullptr)
{
- handler->pluginName = plugin->m_name;
- handler->bWithFile = false;
+ handler->m_PluginName = plugin->m_name;
+ handler->m_bWithFile = false;
// probably it is for VB/VBscript so use a BSTR as argument
bHandled = plugin::InvokePrediffBuffer(*bufferData.GetDataBufferUnicode(),
bufferData.GetNChanged(),
if (!bHandled)
{
// we didn't find any prediffer, that is OK anyway
- handler->pluginName = _T("");
+ handler->m_PluginName = _T("");
bHandled = true;
}
// the handler is now defined
- handler->bToBeScanned = false;
+ handler->m_PluginOrPredifferMode = PLUGIN_MANUAL;
// if the buffer changed, write it before leaving
bool bSuccess = true;
bool Prediffing(PrediffingInfo * handler, String & filepath, const String& filteredText, bool bMayOverwrite)
{
- if (handler->bToBeScanned)
+ if (handler->m_PluginOrPredifferMode != PLUGIN_MANUAL)
return Prediffing(filepath, filteredText, handler, bMayOverwrite);
else
return Prediffing(filepath, *handler, bMayOverwrite);
#include "UnicodeString.h"
#include "MergeApp.h"
-namespace FileTransform
-{
-extern int g_bUnpackerMode;
-extern int g_bPredifferMode;
-}
-
-class UniFile;
-
/**
* @brief Modes for plugin (Modes for prediffing included)
*/
enum PLUGIN_MODE
{
- // Modes for unpacking
+ // Modes for "unpacking"
PLUGIN_MANUAL,
PLUGIN_AUTO,
PLUGIN_BUILTIN_XML,
- // Modes for prediffing
+
+ // Modes for "prediffing"
PREDIFF_MANUAL = PLUGIN_MANUAL,
PREDIFF_AUTO = PLUGIN_AUTO,
};
+namespace FileTransform
+{
+extern PLUGIN_MODE g_UnpackerMode;
+extern PLUGIN_MODE g_PredifferMode;
+}
+
+class UniFile;
+
/**
* @brief Plugin information for a given file
*
class PluginForFile
{
public:
- void Initialize(int bMode)
+ void Initialize(PLUGIN_MODE Mode)
{
- // TODO: Convert bMode to PLUGIN_MODE and fix compile errors
- // init functions as a valid "do nothing" unpacker
- bWithFile = false;
- // and init bAutomatic flag and name according to global variable
- if (bMode != PLUGIN_AUTO)
+ // initialize functions with a valid "do nothing" unpacker
+ m_bWithFile = false;
+ // and init Plugin/Prediffer mode and Plugin name accordingly
+ m_PluginOrPredifferMode = Mode;
+ if (Mode != PLUGIN_AUTO)
{
- pluginName.erase();
+ m_PluginName.erase();
}
else
{
- pluginName = _("<Automatic>");
+ m_PluginName = _("<Automatic>");
}
- bToBeScanned = bMode;
};
- explicit PluginForFile(PLUGIN_MODE bMode)
+ explicit PluginForFile(PLUGIN_MODE Mode)
{
- Initialize(bMode);
+ Initialize(Mode);
};
public:
- /// TRUE if the plugin will be defined during the first use (through scan of all available plugins)
- int bToBeScanned; // TODO: Convert to PLUGIN_MODE and fix compile errors
+ /// PLUGIN_AUTO if the plugin will be defined during the first use (via scan of all available plugins)
+ PLUGIN_MODE m_PluginOrPredifferMode;
+
/// plugin name when it is defined
- String pluginName;
+ String m_PluginName;
/// `true` if the plugins exchange data through a file, `false` is the data is passed as parameter (BSTR/ARRAY)
- bool bWithFile;
+ bool m_bWithFile;
};
/**
class PackingInfo : public PluginForFile
{
public:
- explicit PackingInfo(PLUGIN_MODE bMode = (PLUGIN_MODE)FileTransform::g_bUnpackerMode)
- : PluginForFile(bMode)
- , subcode(0)
- , pufile(nullptr)
- , disallowMixedEOL(false)
+ explicit PackingInfo(PLUGIN_MODE Mode = FileTransform::g_UnpackerMode)
+ : PluginForFile(Mode)
+ , m_subcode(0)
+ , m_pufile(nullptr)
+ , m_bDisallowMixedEOL(false)
{
}
public:
/// keep some info from unpacking for packing
- int subcode;
+ int m_subcode;
/// text type to override syntax highlighting
- String textType;
+ String m_textType;
/// custom UniFile
- UniFile *pufile;
- bool disallowMixedEOL;
+ UniFile* m_pufile;
+ bool m_bDisallowMixedEOL;
};
/**
class PrediffingInfo : public PluginForFile
{
public:
- explicit PrediffingInfo(PLUGIN_MODE bMode = (PLUGIN_MODE)FileTransform::g_bPredifferMode)
- : PluginForFile(bMode)
+ explicit PrediffingInfo(PLUGIN_MODE Mode = FileTransform::g_PredifferMode)
+ : PluginForFile(Mode)
{
}
};
goto exitPrepAndCompare;
// we use the same plugins for both files, so they must be defined before second file
- assert(!infoUnpacker->bToBeScanned);
+ assert(!infoUnpacker->m_PluginOrPredifferMode != PLUGIN_MANUAL);
}
// As we keep handles open on unpacked files, Transform() may not delete them.
if (pDirDoc && !pDirDoc->CloseMergeDocs())
return false;
- FileTransform::g_eUnpackerMode = static_cast<PLUGIN_MODE>(theApp.GetProfileInt(_T("Settings"), _T("UnpackerMode"), PLUGIN_MANUAL));
- FileTransform::g_ePredifferMode = static_cast<PLUGIN_MODE>(theApp.GetProfileInt(_T("Settings"), _T("PredifferMode"), PLUGIN_MANUAL));
+ FileTransform::g_UnpackerMode = static_cast<PLUGIN_MODE>(theApp.GetProfileInt(_T("Settings"), _T("UnpackerMode"), PLUGIN_MANUAL));
+ FileTransform::g_PredifferMode = static_cast<PLUGIN_MODE>(theApp.GetProfileInt(_T("Settings"), _T("PredifferMode"), PLUGIN_MANUAL));
Merge7zFormatMergePluginScope scope(infoUnpacker);
switch (nID)
{
case ID_UNPACK_MANUAL:
- FileTransform::g_bUnpackerMode = PLUGIN_MANUAL;
+ FileTransform::g_UnpackerMode = PLUGIN_MANUAL;
break;
case ID_UNPACK_AUTO:
- FileTransform::g_bUnpackerMode = PLUGIN_AUTO;
+ FileTransform::g_UnpackerMode = PLUGIN_AUTO;
break;
}
- theApp.WriteProfileInt(_T("Settings"), _T("UnpackerMode"), FileTransform::g_bUnpackerMode);
+ theApp.WriteProfileInt(_T("Settings"), _T("UnpackerMode"), FileTransform::g_UnpackerMode);
}
void CMainFrame::OnUpdatePluginUnpackMode(CCmdUI* pCmdUI)
pCmdUI->Enable(GetOptionsMgr()->GetBool(OPT_PLUGINS_ENABLED));
if (pCmdUI->m_nID == ID_UNPACK_MANUAL)
- pCmdUI->SetRadio(PLUGIN_MANUAL == FileTransform::g_bUnpackerMode);
+ pCmdUI->SetRadio(PLUGIN_MANUAL == FileTransform::g_UnpackerMode);
if (pCmdUI->m_nID == ID_UNPACK_AUTO)
- pCmdUI->SetRadio(PLUGIN_AUTO == FileTransform::g_bUnpackerMode);
+ pCmdUI->SetRadio(PLUGIN_AUTO == FileTransform::g_UnpackerMode);
}
void CMainFrame::OnPluginPrediffMode(UINT nID )
{
switch (nID)
{
case ID_PREDIFFER_MANUAL:
- FileTransform::g_bPredifferMode = PLUGIN_MANUAL;
+ FileTransform::g_PredifferMode = PLUGIN_MANUAL;
break;
case ID_PREDIFFER_AUTO:
- FileTransform::g_bPredifferMode = PLUGIN_AUTO;
+ FileTransform::g_PredifferMode = PLUGIN_AUTO;
break;
}
PrediffingInfo infoPrediffer;
for (auto pMergeDoc : GetAllMergeDocs())
pMergeDoc->SetPrediffer(&infoPrediffer);
for (auto pDirDoc : GetAllDirDocs())
- pDirDoc->GetPluginManager().SetPrediffSettingAll(FileTransform::g_bPredifferMode);
- theApp.WriteProfileInt(_T("Settings"), _T("PredifferMode"), FileTransform::g_bPredifferMode);
+ pDirDoc->GetPluginManager().SetPrediffSettingAll(FileTransform::g_PredifferMode);
+ theApp.WriteProfileInt(_T("Settings"), _T("PredifferMode"), FileTransform::g_PredifferMode);
}
void CMainFrame::OnUpdatePluginPrediffMode(CCmdUI* pCmdUI)
pCmdUI->Enable(GetOptionsMgr()->GetBool(OPT_PLUGINS_ENABLED));
if (pCmdUI->m_nID == ID_PREDIFFER_MANUAL)
- pCmdUI->SetRadio(PLUGIN_MANUAL == FileTransform::g_bPredifferMode);
+ pCmdUI->SetRadio(PLUGIN_MANUAL == FileTransform::g_PredifferMode);
if (pCmdUI->m_nID == ID_PREDIFFER_AUTO)
- pCmdUI->SetRadio(PLUGIN_AUTO == FileTransform::g_bPredifferMode);
+ pCmdUI->SetRadio(PLUGIN_AUTO == FileTransform::g_PredifferMode);
}
/**
* @brief Called when "Reload Plugins" item is updated
charsets_init();
UpdateCodepageModule();
- FileTransform::g_bUnpackerMode = theApp.GetProfileInt(_T("Settings"), _T("UnpackerMode"), PLUGIN_MANUAL);
- FileTransform::g_bPredifferMode = theApp.GetProfileInt(_T("Settings"), _T("PredifferMode"), PLUGIN_MANUAL);
+ FileTransform::g_UnpackerMode = static_cast<PLUGIN_MODE>(theApp.GetProfileInt(_T("Settings"), _T("UnpackerMode"), PLUGIN_MANUAL));
+ FileTransform::g_PredifferMode = static_cast<PLUGIN_MODE>(theApp.GetProfileInt(_T("Settings"), _T("PredifferMode"), PLUGIN_MANUAL));
NONCLIENTMETRICS ncm = { sizeof NONCLIENTMETRICS };
if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof NONCLIENTMETRICS, &ncm, 0))
{
Merge7zFormatMergePluginImpl *format = GetInstance();
PluginInfo *plugin = NULL;
- if (format->m_infoUnpacker.bToBeScanned)
+ if (format->m_infoUnpacker.m_PluginOrPredifferMode != PLUGIN_MANUAL)
plugin = CAllThreadsScripts::GetActiveSet()->GetAutomaticPluginByFilter(L"FILE_FOLDER_PACK_UNPACK", path);
- else if (!format->m_infoUnpacker.pluginName.empty())
- plugin = CAllThreadsScripts::GetActiveSet()->GetPluginByName(L"FILE_FOLDER_PACK_UNPACK", format->m_infoUnpacker.pluginName);
+ else if (!format->m_infoUnpacker.m_PluginName.empty())
+ plugin = CAllThreadsScripts::GetActiveSet()->GetPluginByName(L"FILE_FOLDER_PACK_UNPACK", format->m_infoUnpacker.m_PluginName);
if (!plugin)
return NULL;
if (!plugin::InvokeIsFolder(path, plugin->m_lpDispatch))
return E_FAIL;
paths::CreateIfNeeded(path);
int nChanged = 0;
- return plugin::InvokeUnpackFolder(path, folder, nChanged, m_plugin->m_lpDispatch, m_infoUnpacker.subcode) ? S_OK : E_FAIL;
+ return plugin::InvokeUnpackFolder(path, folder, nChanged, m_plugin->m_lpDispatch, m_infoUnpacker.m_subcode) ? S_OK : E_FAIL;
}
HRESULT Merge7zFormatMergePluginImpl::CompressArchive(HWND, LPCTSTR path, Merge7z::DirItemEnumerator *)
// Apply flags to lines that are trivial
PrediffingInfo infoPrediffer;
GetPrediffer(&infoPrediffer);
- if (!infoPrediffer.pluginName.empty())
+ if (!infoPrediffer.m_PluginName.empty())
FlagTrivialLines();
// Apply flags to lines that moved, to differentiate from appeared/disappeared lines
: (nBuffer == 1 ?
_("Plugin '%2' cannot pack your changes to the middle file back into '%1'.\n\nThe original file will not be changed.\n\nDo you want to save the unpacked version to another file?"):
_("Plugin '%2' cannot pack your changes to the right file back into '%1'.\n\nThe original file will not be changed.\n\nDo you want to save the unpacked version to another file?")),
- strPath, pInfoTempUnpacker->pluginName);
+ strPath, pInfoTempUnpacker->m_PluginName);
}
else
{
str = strutils::format_string2(nBuffer == 0 ? _("Plugin '%2' cannot pack your changes to the left file back into '%1'.\n\nThe original file will not be changed.\n\nDo you want to save the unpacked version to another file?") :
_("Plugin '%2' cannot pack your changes to the right file back into '%1'.\n\nThe original file will not be changed.\n\nDo you want to save the unpacked version to another file?"),
- strPath, pInfoTempUnpacker->pluginName);
+ strPath, pInfoTempUnpacker->m_PluginName);
}
// replace the unpacker with a "do nothing" unpacker
pInfoTempUnpacker->Initialize(PLUGIN_MANUAL);
void CMergeDoc::OnUpdatePluginName(CCmdUI* pCmdUI)
{
String pluginNames;
- if (m_pInfoUnpacker && !m_pInfoUnpacker->pluginName.empty())
- pluginNames += m_pInfoUnpacker->pluginName + _T("&");
+ if (m_pInfoUnpacker && !m_pInfoUnpacker->m_PluginName.empty())
+ pluginNames += m_pInfoUnpacker->m_PluginName + _T("&");
PrediffingInfo prediffer;
GetPrediffer(&prediffer);
- if (!prediffer.pluginName.empty())
- pluginNames += prediffer.pluginName + _T("&");
+ if (!prediffer.m_PluginName.empty())
+ pluginNames += prediffer.m_PluginName + _T("&");
pCmdUI->SetText(pluginNames.substr(0, pluginNames.length() - 1).c_str());
}
for (nBuffer = 0; nBuffer < m_nBuffers; nBuffer++)
{
- if (bFiltersEnabled && m_pInfoUnpacker->textType.length())
- sext[nBuffer] = m_pInfoUnpacker->textType;
+ if (bFiltersEnabled && m_pInfoUnpacker->m_textType.length())
+ sext[nBuffer] = m_pInfoUnpacker->m_textType;
else
sext[nBuffer] = GetFileExt(fileloc[nBuffer].filepath.c_str(), m_strDesc[nBuffer].c_str());
ForEachView(nBuffer, [&](auto& pView) {
PrediffingInfo prediffer;
pd->GetPrediffer(&prediffer);
- if (prediffer.bToBeScanned)
+ if (prediffer.m_PluginOrPredifferMode != PLUGIN_MANUAL)
m_CurrentPredifferID = 0;
- else if (prediffer.pluginName.empty())
+ else if (prediffer.m_PluginName.empty())
m_CurrentPredifferID = ID_NO_PREDIFFER;
else
{
for (iScript = 0 ; iScript < piScriptArray->size() ; iScript++, ID ++)
{
const PluginInfoPtr & plugin = piScriptArray->at(iScript);
- if (prediffer.pluginName == plugin->m_name)
+ if (prediffer.m_PluginName == plugin->m_name)
m_CurrentPredifferID = ID;
}
for (iScript = 0 ; iScript < piScriptArray2->size() ; iScript++, ID ++)
{
const PluginInfoPtr & plugin = piScriptArray2->at(iScript);
- if (prediffer.pluginName == plugin->m_name)
+ if (prediffer.m_PluginName == plugin->m_name)
m_CurrentPredifferID = ID;
}
}
PrediffingInfo prediffer;
pd->GetPrediffer(&prediffer);
- if (prediffer.bToBeScanned)
+ if (prediffer.m_PluginOrPredifferMode != PLUGIN_MANUAL)
{
pCmdUI->SetRadio(false);
return;
}
// Detect when CDiffWrapper::RunFileDiff has canceled a buggy prediffer
- if (prediffer.pluginName.empty())
+ if (prediffer.m_PluginName.empty())
m_CurrentPredifferID = ID_NO_PREDIFFER;
pCmdUI->SetRadio(pCmdUI->m_nID == static_cast<UINT>(m_CurrentPredifferID));
m_CurrentPredifferID = nID;
// All flags are set correctly during the construction
PrediffingInfo *infoPrediffer = new PrediffingInfo;
- infoPrediffer->bToBeScanned = 0;
- infoPrediffer->pluginName.clear();
+ infoPrediffer->m_PluginOrPredifferMode = PLUGIN_MANUAL;
+ infoPrediffer->m_PluginName.clear();
pd->SetPrediffer(infoPrediffer);
pd->FlushAndRescan(true);
return;
// build a PrediffingInfo structure fom the ID
PrediffingInfo prediffer;
- prediffer.bToBeScanned = false;
+ prediffer.m_PluginOrPredifferMode = PLUGIN_MANUAL;
size_t pluginNumber = nID - ID_PREDIFFERS_FIRST;
if (pluginNumber < piScriptArray->size())
{
- prediffer.bWithFile = true;
+ prediffer.m_bWithFile = true;
const PluginInfoPtr & plugin = piScriptArray->at(pluginNumber);
- prediffer.pluginName = plugin->m_name;
+ prediffer.m_PluginName = plugin->m_name;
}
else
{
pluginNumber -= piScriptArray->size();
if (pluginNumber >= piScriptArray2->size())
return;
- prediffer.bWithFile = false;
+ prediffer.m_bWithFile = false;
const PluginInfoPtr & plugin = piScriptArray2->at(pluginNumber);
- prediffer.pluginName = plugin->m_name;
+ prediffer.m_PluginName = plugin->m_name;
}
// update data for the radio button
if (!bOverwriteRecursive)
m_bRecurse = GetOptionsMgr()->GetBool(OPT_CMP_INCLUDE_SUBDIRS);
- m_strUnpacker = m_infoHandler.pluginName;
+ m_strUnpacker = m_infoHandler.m_PluginName;
UpdateData(FALSE);
SetStatus(IDS_OPEN_FILESDIRS);
SetUnpackerStatus(IDS_USERCHOICE_NONE);
void COpenView::UpdateResources()
{
theApp.m_pLangDlg->RetranslateDialog(m_hWnd, MAKEINTRESOURCE(IDD_OPEN));
- if (m_strUnpacker != m_infoHandler.pluginName)
+ if (m_strUnpacker != m_infoHandler.m_PluginName)
m_strUnpacker = theApp.LoadString(IDS_OPEN_UNPACKERDISABLED);
}
{
m_infoHandler = dlg.GetInfoHandler();
- m_strUnpacker = m_infoHandler.pluginName;
+ m_strUnpacker = m_infoHandler.m_PluginName;
UpdateData(FALSE);
}
/**
* @brief Store specified prediff choice for specified comparison
*/
-void PluginManager::SetPrediffSetting(const String& filteredFilenames, int newsetting)
+void PluginManager::SetPrediffSetting(const String& filteredFilenames, PLUGIN_MODE newsetting)
{
PackingInfo * infoUnpacker = nullptr;
PrediffingInfo * infoPrediffer = nullptr;
infoPrediffer->Initialize(newsetting);
}
-void PluginManager::SetPrediffSettingAll(int newsetting)
+void PluginManager::SetPrediffSettingAll(PLUGIN_MODE newsetting)
{
FastMutex::ScopedLock lock(m_mutex);
for (PluginFileInfoMap::iterator it = m_pluginSettings.begin(); it != m_pluginSettings.end(); ++it)
PackingInfo * infoUnpacker = nullptr;
PrediffingInfo * infoPrediffer = nullptr;
FetchPluginInfos(filteredFilenames, &infoUnpacker, &infoPrediffer);
- infoPrediffer->pluginName = prediffer;
+ infoPrediffer->m_PluginName = prediffer;
}
\ No newline at end of file
typedef std::map<String, PluginFileInfoPtr> PluginFileInfoMap;
~PluginManager();
- void SetPrediffSetting(const String& filteredFilenames, int newsetting);
- void SetPrediffSettingAll(int newsetting);
+ void SetPrediffSetting(const String& filteredFilenames, PLUGIN_MODE newsetting);
+ void SetPrediffSettingAll(PLUGIN_MODE newsetting);
void SetPrediffer(const String& filteredFilenames, const String& prediffer);
// Implement IPluginInfos
virtual void FetchPluginInfos(const String& filteredFilenames,
// default value
m_pPlugin = noPlugin.get();
- if (infoHandler && infoHandler->bToBeScanned)
+ if (infoHandler != nullptr && infoHandler->m_PluginOrPredifferMode != PLUGIN_MANUAL)
// automatic unpacker
m_pPlugin = automaticPlugin.get();
else if (infoHandler)
for (i = 0 ; i < m_UnpackerPlugins.GetSize() ; i++)
{
PluginInfo * pPlugin = static_cast<PluginInfo*> (m_UnpackerPlugins.GetAt(i));
- if (pPlugin->m_name == infoHandler->pluginName)
+ if (pPlugin->m_name == infoHandler->m_PluginName)
m_pPlugin = pPlugin;
}
}
{
// build a real plugin unpacker
PackingInfo infoHandler;
- infoHandler.bToBeScanned = FALSE;
- infoHandler.pluginName = m_strPluginName;
+ infoHandler.m_PluginOrPredifferMode = PLUGIN_MANUAL;
+ infoHandler.m_PluginName = m_strPluginName;
int i;
for (i = 0 ; i < m_UnpackerPlugins.GetSize() ; i++)
{
if (m_pPlugin == pPlugin)
break;
}
- infoHandler.bWithFile = m_bWithFileFlags.at(i);
+ infoHandler.m_bWithFile = m_bWithFileFlags.at(i);
return infoHandler;
}
}
IPluginInfos *ppi = ±
ppi->FetchPluginInfos(_T("../../Data/Office/excel.xls|../../Data/Office/excel.xls"), &iu, &ip);
String file = paths::ConcatPath(oldModulePath, _T("..\\..\\Data\\Office\\excel.xls"));
- FileTransform::Unpacking(file, _T(".*\\.xls"), iu, &iu->subcode);
+ FileTransform::Unpacking(file, _T(".*\\.xls"), iu, &iu->m_subcode);
}
} // namespace