MCPcopy Create free account
hub / github.com/amule-project/amule / InstallDesktopFile

Function InstallDesktopFile

src/AppImageIntegration.cpp:91–127  ·  view source on GitHub ↗

Read the bundled .desktop, swap Exec= and TryExec= to point at $APPIMAGE, and write the result to ~/.local/share/applications/org.amule.aMule.desktop. Returns true on success.

Source from the content-addressed store, hash-verified

89// and write the result to ~/.local/share/applications/org.amule.aMule.desktop.
90// Returns true on success.
91bool InstallDesktopFile(const wxString& appimagePath, const wxString& sourceDesktop, const wxString& destDesktop)
92{
93 wxTextFile in(sourceDesktop);
94 if (!in.Open()) {
95 AddDebugLogLineC(logGeneral,
96 wxT("AppImageIntegration: failed to open ") + sourceDesktop);
97 return false;
98 }
99
100 wxTextFile out(destDesktop);
101 if (out.Exists()) {
102 out.Open();
103 out.Clear();
104 } else if (!out.Create()) {
105 AddDebugLogLineC(logGeneral,
106 wxT("AppImageIntegration: failed to create ") + destDesktop);
107 return false;
108 }
109
110 for (size_t i = 0; i < in.GetLineCount(); ++i) {
111 wxString line = in[i];
112 if (line.StartsWith(wxT("Exec="))) {
113 // Quote the AppImage path so spaces survive; %F passes file
114 // arguments from the shell when the launcher is invoked with
115 // drag-and-drop or "Open With".
116 line = wxT("Exec=\"") + appimagePath + wxT("\" %F");
117 } else if (line.StartsWith(wxT("TryExec="))) {
118 line = wxT("TryExec=") + appimagePath;
119 }
120 out.AddLine(line);
121 }
122
123 bool ok = out.Write();
124 in.Close();
125 out.Close();
126 return ok;
127}
128
129// Walk $APPDIR/usr/share/icons/hicolor and mirror the org.amule.aMule.* PNG
130// files into ~/.local/share/icons/hicolor preserving the size subdirs.

Callers 1

PromptAndInstallFunction · 0.85

Calls 6

StartsWithMethod · 0.80
OpenMethod · 0.45
ClearMethod · 0.45
CreateMethod · 0.45
WriteMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected