MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / createShortCut

Function createShortCut

launcher/FileSystem.cpp:368–400  ·  view source on GitHub ↗

Cross-platform Shortcut creation

Source from the content-addressed store, hash-verified

366
367// Cross-platform Shortcut creation
368bool createShortCut(QString location, QString dest, QStringList args, QString name, QString icon)
369{
370#if !defined(Q_OS_WIN) && !defined(Q_OS_OSX)
371 location = PathCombine(location, name + ".desktop");
372
373 QFile f(location);
374 f.open(QIODevice::WriteOnly | QIODevice::Text);
375 QTextStream stream(&f);
376
377 QString argstring;
378 if (!args.empty())
379 argstring = " '" + args.join("' '") + "'";
380
381 stream << "[Desktop Entry]"
382 << "\n";
383 stream << "Type=Application"
384 << "\n";
385 stream << "TryExec=" << dest.toLocal8Bit() << "\n";
386 stream << "Exec=" << dest.toLocal8Bit() << argstring.toLocal8Bit() << "\n";
387 stream << "Name=" << name.toLocal8Bit() << "\n";
388 stream << "Icon=" << icon.toLocal8Bit() << "\n";
389
390 stream.flush();
391 f.close();
392
393 f.setPermissions(f.permissions() | QFileDevice::ExeOwner | QFileDevice::ExeGroup | QFileDevice::ExeOther);
394
395 return true;
396#else
397 qWarning("Desktop Shortcuts not supported on your platform!");
398 return false;
399#endif
400}
401
402bool mergeFolders(QString dstpath, QString srcpath)
403{

Callers

nothing calls this directly

Calls 3

PathCombineFunction · 0.85
openMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected