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

Function ExportSingleFileKml

libs/map/bookmark_manager.cpp:95–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95BookmarkManager::SharingResult ExportSingleFileKml(
96 BookmarkManager::KMLDataCollectionPtr::element_type::value_type const & kmlToShare)
97{
98 std::string const fileName = GetFileNameForExport(kmlToShare);
99
100 auto const filePath = base::JoinPath(GetPlatform().TmpDir(), fileName + std::string{kKmlExtension});
101 SCOPE_GUARD(fileGuard, std::bind(&base::DeleteFileX, filePath));
102
103 auto const categoryId = kmlToShare.second->m_categoryData.m_id;
104
105 if (!SaveKmlFileSafe(*kmlToShare.second, filePath, KmlFileType::Text))
106 return {{categoryId}, BookmarkManager::SharingResult::Code::FileError, "Bookmarks file does not exist."};
107
108 auto tmpFilePath = base::JoinPath(GetPlatform().TmpDir(), fileName + std::string{kKmzExtension});
109
110 if (!CreateZipFromFiles({filePath}, tmpFilePath))
111 return {{categoryId}, BookmarkManager::SharingResult::Code::ArchiveError, "Could not create archive."};
112
113 return {{categoryId}, std::move(tmpFilePath), kKMZMimeType};
114}
115
116BookmarkManager::SharingResult ExportSingleFileGpx(
117 BookmarkManager::KMLDataCollectionPtr::element_type::value_type const & kmlToShare)

Callers 1

GetFileForSharingFunction · 0.85

Calls 5

GetFileNameForExportFunction · 0.85
JoinPathFunction · 0.85
SaveKmlFileSafeFunction · 0.85
CreateZipFromFilesFunction · 0.85
TmpDirMethod · 0.80

Tested by

no test coverage detected