MCPcopy Create free account
hub / github.com/comaps/comaps / PrepareToSaveBookmarks

Method PrepareToSaveBookmarks

libs/map/bookmark_manager.cpp:3092–3129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3090}
3091
3092BookmarkManager::KMLDataCollectionPtr BookmarkManager::PrepareToSaveBookmarks(
3093 kml::GroupIdCollection const & groupIdCollection)
3094{
3095 CHECK_THREAD_CHECKER(m_threadChecker, ());
3096
3097 std::string const fileDir = GetBookmarksDirectory();
3098
3099 if (!Platform::IsFileExistsByFullPath(fileDir) && !Platform::MkDirChecked(fileDir))
3100 return nullptr;
3101
3102 auto collection = std::make_shared<KMLDataCollection>();
3103 for (auto const groupId : groupIdCollection)
3104 {
3105 auto * group = GetBmCategory(groupId);
3106
3107 // Get valid file name from category name
3108 std::string file = group->GetFileName();
3109 if (file.empty())
3110 {
3111 std::string name = RemoveInvalidSymbols(group->GetName());
3112 if (name.empty())
3113 name = kDefaultBookmarksFileName;
3114
3115 file = GenerateUniqueFileName(fileDir, std::move(name), kKmlExtension);
3116 group->SetFileName(file);
3117 // Only append to the custom order if it has been activated (non-empty).
3118 if (!m_metadata.m_categoryOrder.empty())
3119 {
3120 auto const fileBasename = base::FileNameFromFullPath(file);
3121 if (std::find(m_metadata.m_categoryOrder.begin(), m_metadata.m_categoryOrder.end(), fileBasename) == m_metadata.m_categoryOrder.end())
3122 m_metadata.m_categoryOrder.push_back(fileBasename);
3123 }
3124 }
3125
3126 collection->emplace_back(std::move(file), CollectBmGroupKMLData(group));
3127 }
3128 return collection;
3129}
3130
3131void BookmarkManager::SaveBookmarks(kml::GroupIdCollection const & groupIdCollection)
3132{

Callers

nothing calls this directly

Calls 13

GetBookmarksDirectoryFunction · 0.85
RemoveInvalidSymbolsFunction · 0.85
GenerateUniqueFileNameFunction · 0.85
FileNameFromFullPathFunction · 0.85
findFunction · 0.85
SetFileNameMethod · 0.80
GetFileNameMethod · 0.45
emptyMethod · 0.45
GetNameMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected