xi-desktop-portals

Simpler specifications for Linux desktop APIs.
git clone https://git.ce9e.org/xi-desktop-portals.git

commit
c74b55588541af0ff9950c55b05e02ded5ea24d1
parent
f9c1ec414b69f383b42ef050405da550a5c52235
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2026-03-15 09:02
[OpenURI] allow to pass absolute paths

Diffstat

M OpenURI/open-uri.c 13 +++++++++++++

1 files changed, 13 insertions, 0 deletions


diff --git a/OpenURI/open-uri.c b/OpenURI/open-uri.c

@@ -25,6 +25,13 @@ int get_pidfd(int sock) {
   25    25     return pidfd;
   26    26 }
   27    27 
   -1    28 char *path_to_uri(char *path) {
   -1    29     GFile *file = g_file_new_for_path(path);
   -1    30     char *uri = g_file_get_uri(file);
   -1    31     g_object_unref(file);
   -1    32     return uri;
   -1    33 }
   -1    34 
   28    35 char *uri_to_path(char *uri) {
   29    36     GFile *file = g_file_new_for_uri(uri);
   30    37     char *path = g_file_get_path(file);
@@ -107,6 +114,12 @@ int main() {
  107   114     uri[n] = '\0';
  108   115     g_strchomp(uri);
  109   116 
   -1   117     if (strncmp(uri, "/", 1) == 0) {
   -1   118         char *tmp = path_to_uri(uri);
   -1   119         snprintf(uri, sizeof(uri), "%s", tmp);
   -1   120         free(tmp);
   -1   121     }
   -1   122 
  110   123     if (strncmp(uri, "file://", 7) == 0) {
  111   124         int pidfd = get_pidfd(SOCK);
  112   125         if (pidfd < 0) {