summaryrefslogtreecommitdiff
path: root/os-posix.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-08-04 21:39:13 -0400
committerpommicket <pommicket@gmail.com>2023-08-04 21:42:53 -0400
commit49ab483be3e7af88a3932a43f222aa42cacd3515 (patch)
tree9ad0157a22ed6cd9c54458b6c75ffa7eaa2253e7 /os-posix.c
parentce199f9384f9f9376417110574a07cfd731e3a79 (diff)
document links seem to be working
Diffstat (limited to 'os-posix.c')
-rw-r--r--os-posix.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/os-posix.c b/os-posix.c
index ca950b1..4485845 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -388,3 +388,23 @@ int process_check_status(Process **pproc, ProcessExitInfo *info) {
return -1;
}
}
+
+bool open_with_default_application(const char *path) {
+ const char *cmd = NULL;
+#if __linux__
+ cmd = "xdg-open";
+#elif __APPLE__
+ cmd = "open";
+#endif
+ if (!cmd)
+ return false;
+ switch (fork()) {
+ case 0:
+ execlp(cmd, cmd, path, NULL);
+ abort();
+ case -1:
+ return false;
+ default:
+ return true;
+ }
+}