| 93 | } |
| 94 | |
| 95 | BookmarkManager::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 | |
| 116 | BookmarkManager::SharingResult ExportSingleFileGpx( |
| 117 | BookmarkManager::KMLDataCollectionPtr::element_type::value_type const & kmlToShare) |
no test coverage detected