Skip to content

Commit

Permalink
Fix wi'ndow
Browse files Browse the repository at this point in the history
  • Loading branch information
Beyley committed Aug 22, 2023
1 parent 63a09c6 commit 68648b1
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions src/config.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ const known_folders = @import("known-folders");

const c = @import("c.zig").c;

const win32 = @cImport({
@cDefine("WIN32_LEAN_AND_MEAN", "1");
@cInclude("windows.h");
@cInclude("shellapi.h");
});

const Self = @This();

instance_url: []const u8 = "https://refresh.jvyden.xyz/",
Expand Down Expand Up @@ -60,17 +66,23 @@ pub fn getConfig(allocator: std.mem.Allocator) !Self {
c.BoxerStyleInfo,
c.BoxerButtonsYesNo,
) == c.BoxerSelectionYes) {
var child_process = std.ChildProcess.init(
switch (builtin.os.tag) {
.windows => &.{full_path},
.linux => &.{ "xdg-open", full_path },
.macos => &.{ "open", full_path },
else => @compileError("Unknown platform!"),
},
allocator,
);
try child_process.spawn();
_ = try child_process.wait();
if (builtin.os.tag == .windows) {
var windows_path = try std.unicode.utf8ToUtf16LeWithNull(allocator, full_path);
defer allocator.free(windows_path);

_ = win32.ShellExecuteW(null, std.unicode.utf8ToUtf16LeStringLiteral("edit"), windows_path, null, null, 0);
} else {
var child_process = std.ChildProcess.init(
switch (builtin.os.tag) {
.linux => &.{ "xdg-open", full_path },
.macos => &.{ "open", full_path },
else => @compileError("Unknown platform!"),
},
allocator,
);
try child_process.spawn();
_ = try child_process.wait();
}
}

std.os.exit(0);
Expand Down

0 comments on commit 68648b1

Please sign in to comment.