MCPcopy Create free account
hub / github.com/Kitware/CMake / CreateFoldersAndFiles

Method CreateFoldersAndFiles

Source/cmExtraCodeLiteGenerator.cxx:320–384  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

318}
319
320void cmExtraCodeLiteGenerator::CreateFoldersAndFiles(
321 std::set<std::string>& cFiles, cmXMLWriter& xml,
322 std::string const& projectPath)
323{
324 std::vector<std::string> tmp_path;
325 std::vector<std::string> components;
326 size_t numOfEndEl = 0;
327
328 for (std::string const& cFile : cFiles) {
329 std::string frelapath = cmSystemTools::RelativePath(projectPath, cFile);
330 cmsys::SystemTools::SplitPath(frelapath, components, false);
331 components.pop_back(); // erase last member -> it is file, not folder
332 components.erase(components.begin()); // erase "root"
333
334 size_t sizeOfSkip = 0;
335
336 for (size_t i = 0; i < components.size(); ++i) {
337 // skip relative path
338 if (components[i] == ".." || components[i] == ".") {
339 sizeOfSkip++;
340 continue;
341 }
342
343 // same folder
344 if (tmp_path.size() > i - sizeOfSkip &&
345 tmp_path[i - sizeOfSkip] == components[i]) {
346 continue;
347 }
348
349 // delete "old" subfolders
350 if (tmp_path.size() > i - sizeOfSkip) {
351 numOfEndEl = tmp_path.size() - i + sizeOfSkip;
352 tmp_path.erase(tmp_path.end() - numOfEndEl, tmp_path.end());
353 for (; numOfEndEl--;) {
354 xml.EndElement();
355 }
356 }
357
358 // add folder
359 xml.StartElement("VirtualDirectory");
360 xml.Attribute("Name", components[i]);
361 tmp_path.push_back(components[i]);
362 }
363
364 // delete "old" subfolders
365 numOfEndEl = tmp_path.size() - components.size() + sizeOfSkip;
366 if (numOfEndEl) {
367 tmp_path.erase(tmp_path.end() - numOfEndEl, tmp_path.end());
368 for (; numOfEndEl--;) {
369 xml.EndElement();
370 }
371 }
372
373 // add file
374 xml.StartElement("File");
375 xml.Attribute("Name", frelapath);
376 xml.EndElement();
377 }

Callers 1

Calls 10

pop_backMethod · 0.80
eraseMethod · 0.80
AttributeMethod · 0.80
push_backMethod · 0.80
beginMethod · 0.45
sizeMethod · 0.45
endMethod · 0.45
EndElementMethod · 0.45
StartElementMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected