@@ -232,39 +232,11 @@ namespace appimage {
232
232
// Generate deploy paths
233
233
std::map<std::string, std::string> mimeTypeIconsTargetPaths;
234
234
for (const auto & path: mimeTypeIconPaths)
235
- mimeTypeIconsTargetPaths[path] = generateMimeTypeIconDeployPath (path).string ();
235
+ mimeTypeIconsTargetPaths[path] = generateDeployPath (path).string ();
236
236
237
237
resourcesExtractor.extractTo (mimeTypeIconsTargetPaths);
238
238
}
239
239
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
-
268
240
/* *
269
241
* Deploy <iconData> as the main application icon to
270
242
* XDG_DATA_HOME/icons/hicolor/<size>/<iconGroup>/<vendorPrefix>_<appImageId>_<iconName>.<format extension>
@@ -311,18 +283,29 @@ namespace appimage {
311
283
}
312
284
313
285
/* *
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
315
287
* this file. Replace the default XDG_DATA_DIR by the one at <xdgDataHome>
316
288
*
317
289
* @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>
319
291
*/
320
292
bf::path generateDeployPath (bf::path path) const {
321
293
// add appImage resource identification prefix to the filename
322
294
std::stringstream fileNameBuilder;
323
295
fileNameBuilder << VENDOR_PREFIX << " _" << appImageId << " _" << path.filename ().string ();
324
296
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 {
326
309
path.remove_filename ();
327
310
bf::path relativeParentPath;
328
311
const bf::path defaultXdgDataDirPath = " usr/share" ;
@@ -333,20 +316,20 @@ namespace appimage {
333
316
if (relativeParentPath == defaultXdgDataDirPath)
334
317
relativeParentPath.clear ();
335
318
}
336
-
337
- bf::path newPath = xdgDataHome / relativeParentPath / fileNameBuilder.str ();
338
- return newPath;
319
+ return relativeParentPath;
339
320
}
340
321
341
322
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
+ }
350
333
}
351
334
352
335
void setExecutionPermission () {
0 commit comments