MCPcopy Create free account
hub / github.com/WinMerge/winmerge / GetPackUnpackPlugin

Method GetPackUnpackPlugin

Src/FileTransform.cpp:306–442  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

304}
305
306bool PackingInfo::GetPackUnpackPlugin(const String& filteredFilenames, bool bUrl, bool bReverse,
307 std::vector<std::tuple<PluginInfo*, uint8_t, std::vector<String>, bool>>& plugins,
308 String *pPluginPipelineResolved, String& errorMessage) const
309{
310 auto result = ExpandAliases(this->m_PluginPipeline, filteredFilenames, L"ALIAS_PACK_UNPACK", errorMessage);
311 if (!errorMessage.empty())
312 return false;
313 if (bUrl)
314 {
315 uint8_t targetFlags = 0xff;
316 std::vector<String> args;
317 const auto filenames = strutils::split(filteredFilenames, '|');
318 std::vector<std::pair<PluginInfo*, bool>> pluginInfos;
319 for (int i = 0; i < filenames.size(); ++i)
320 {
321 bool bWithFile = true;
322 const String filename{ filenames[i].data(), filenames[i].size() };
323 PluginInfo* plugin = nullptr;
324 plugin = CAllThreadsScripts::GetActiveSet()->GetAutomaticPluginByFilter(L"URL_PACK_UNPACK", filename);
325 pluginInfos.push_back({ plugin, bWithFile });
326 }
327 if (!filenames.empty() &&
328 std::all_of(pluginInfos.begin() + 1, pluginInfos.end(),
329 [&](const auto& elem) { return elem == pluginInfos.front(); }))
330 {
331 const auto& pluginInfo = pluginInfos.front();
332 if (pluginInfo.first)
333 {
334 plugins.insert(bReverse ? plugins.begin() : plugins.end(),
335 { pluginInfo.first, targetFlags, args, pluginInfo.second });
336 }
337 }
338 else
339 {
340 for (int i = 0; i < pluginInfos.size(); ++i)
341 {
342 const auto& pluginInfo = pluginInfos[i];
343 if (isTargetInFlags(i, targetFlags) && pluginInfo.first)
344 {
345 uint8_t targetFlags2 = 1 << i;
346 plugins.insert(bReverse ? plugins.begin() : plugins.end(),
347 { pluginInfo.first, targetFlags2, args, pluginInfo.second });
348 }
349 }
350 }
351 }
352 std::vector<PluginForFile::PipelineItem> pipelineResolved;
353 for (auto& [pluginName, targetFlags, args, quoteChar] : result)
354 {
355 PluginInfo* plugin = nullptr;
356 if (pluginName == _T("<None>") || pluginName == _("<None>"))
357 ;
358 else if (pluginName == _T("<Automatic>") || pluginName == _("<Automatic>"))
359 {
360 const auto filenames = strutils::split(filteredFilenames, '|');
361 std::vector<std::pair<PluginInfo*, bool>> pluginInfos;
362 for (int i = 0; i < filenames.size(); ++i)
363 {

Callers

nothing calls this directly

Calls 13

ExpandAliasesFunction · 0.85
splitFunction · 0.85
isTargetInFlagsFunction · 0.85
GetPluginByNameMethod · 0.80
format_string1Function · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
frontMethod · 0.45

Tested by

no test coverage detected