Skip to content

Commit

Permalink
maybe fix for #56
Browse files Browse the repository at this point in the history
  • Loading branch information
yatima1460 committed Feb 7, 2020
1 parent 312ae0f commit 3fddb34
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions Core/Utils.d
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import std.experimental.logger;
import std.uni : toLower;
import std.path : extension;
import std.process : executeShell;

import GTKBinds;


version(linux) @system string[] getDesktopFiles()
Expand Down Expand Up @@ -40,7 +40,7 @@ Opens a file using the current system implementation for file associations
Returns: true if successful
*/
@safe bool openFile(immutable string fullpath)
bool openFile(immutable string fullpath)
{
// FIXME: return false when no file association
import std.process : spawnProcess;
Expand All @@ -58,16 +58,26 @@ Returns: true if successful
version (linux)
{
immutable auto ext = toLower(extension(fullpath));

// FIXME: folders ending in .AppImage are broken
switch (ext)
{
case ".appimage":
info("File "~fullpath~" detected as .AppImage");
immutable auto cmd = executeShell("chmod +x "~fullpath);
if (cmd.status != 0)
{
critical("Can't set AppImage '"~fullpath~"' as executable.");
// TODO: GTK messagebox here or throw a DrillException?
return false;
error("Can't set AppImage '"~fullpath~"' as executable.");
import std.string : toStringz;
auto dialog = gtk_message_dialog_new (null,
GtkDialogFlags.GTK_DIALOG_MODAL,
GtkMessageType.GTK_MESSAGE_ERROR,
GtkButtonsType.GTK_BUTTONS_CLOSE,

toStringz("Can't set AppImage '"~fullpath~"' as executable."));
gtk_dialog_run (cast(GtkDialog*)dialog);
gtk_widget_destroy (dialog);

}
spawnProcess([fullpath], null, Config.detached, null);
return true;
Expand Down

0 comments on commit 3fddb34

Please sign in to comment.