@@ -232,39 +232,11 @@ namespace appimage {
232232 // Generate deploy paths
233233 std::map<std::string, std::string> mimeTypeIconsTargetPaths;
234234 for (const auto & path: mimeTypeIconPaths)
235- mimeTypeIconsTargetPaths[path] = generateMimeTypeIconDeployPath (path).string ();
235+ mimeTypeIconsTargetPaths[path] = generateDeployPath (path).string ();
236236
237237 resourcesExtractor.extractTo (mimeTypeIconsTargetPaths);
238238 }
239239
240- /* *
241- * Append vendor prefix and appImage id to the file names to identify the appImage that owns
242- * this file. Replace the default XDG_DATA_DIR by the one at <xdgDataHome>
243- *
244- * @param path resource path
245- * @return path with a prefixed file name
246- */
247- bf::path generateMimeTypeIconDeployPath (bf::path path) const {
248- // add appImage resource identification prefix to the filename
249- std::stringstream fileNameBuilder;
250- fileNameBuilder << path.stem () << " -" << VENDOR_PREFIX << " -" << appImageId << path.extension ();
251-
252- // build the relative parent path ignoring the default XDG_DATA_DIR prefix ("usr/share")
253- path.remove_filename ();
254- bf::path relativeParentPath;
255- const bf::path defaultXdgDataDirPath = " usr/share" ;
256-
257- for (const auto & itr : path) {
258- relativeParentPath /= itr;
259-
260- if (relativeParentPath == defaultXdgDataDirPath)
261- relativeParentPath.clear ();
262- }
263-
264- bf::path newPath = xdgDataHome / relativeParentPath / fileNameBuilder.str ();
265- return newPath;
266- }
267-
268240 /* *
269241 * Deploy <iconData> as the main application icon to
270242 * XDG_DATA_HOME/icons/hicolor/<size>/<iconGroup>/<vendorPrefix>_<appImageId>_<iconName>.<format extension>
@@ -311,18 +283,29 @@ namespace appimage {
311283 }
312284
313285 /* *
314- * Append vendor prefix and appImage id to the file names to identify the appImage that owns
286+ * Prepend vendor prefix and appImage id to the file names to identify the appImage that owns
315287 * this file. Replace the default XDG_DATA_DIR by the one at <xdgDataHome>
316288 *
317289 * @param path resource path
318- * @return path with a prefixed file name
290+ * @return <xdg data home>/<relative path>/<vendor prefix>_<appImageId>_< file name>.<extension>
319291 */
320292 bf::path generateDeployPath (bf::path path) const {
321293 // add appImage resource identification prefix to the filename
322294 std::stringstream fileNameBuilder;
323295 fileNameBuilder << VENDOR_PREFIX << " _" << appImageId << " _" << path.filename ().string ();
324296
325- // build the relative parent path ignoring the default XDG_DATA_DIR prefix ("usr/share")
297+ boost::filesystem::path relativeParentPath = generateDeployParentPath (path);
298+
299+ bf::path newPath = xdgDataHome / relativeParentPath / fileNameBuilder.str ();
300+ return newPath;
301+ }
302+
303+ /* *
304+ * Build the relative parent path ignoring the default XDG_DATA_DIR prefix ("usr/share")
305+ * @param path
306+ * @return
307+ */
308+ boost::filesystem::path generateDeployParentPath (boost::filesystem::path& path) const {
326309 path.remove_filename ();
327310 bf::path relativeParentPath;
328311 const bf::path defaultXdgDataDirPath = " usr/share" ;
@@ -333,20 +316,20 @@ namespace appimage {
333316 if (relativeParentPath == defaultXdgDataDirPath)
334317 relativeParentPath.clear ();
335318 }
336-
337- bf::path newPath = xdgDataHome / relativeParentPath / fileNameBuilder.str ();
338- return newPath;
319+ return relativeParentPath;
339320 }
340321
341322 void deployMimeTypePackages () {
342- auto mimeTypePackagesPaths = resourcesExtractor.getMimeTypePackagesPaths ();
343- std::map<std::string, std::string> mimeTypePackagesTargetPaths;
344-
345- // Generate deploy paths
346- for (const auto & path: mimeTypePackagesPaths)
347- mimeTypePackagesTargetPaths[path] = generateDeployPath (path).string ();
348-
349- resourcesExtractor.extractTo (mimeTypePackagesTargetPaths);
323+ for (auto & itr: mimeInfoFiles) {
324+ MimeInfoEditor& editor = itr.second ;
325+ editor.setDeployId (VENDOR_PREFIX + ' _' + appImageId);
326+ boost::filesystem::path deployPath = generateDeployPath (itr.first );
327+
328+ create_directories (deployPath.parent_path ());
329+ std::ofstream out (deployPath.string ());
330+ out << editor.edit ();
331+ out.close ();
332+ }
350333 }
351334
352335 void setExecutionPermission () {
0 commit comments