diff mupdf-source/thirdparty/tesseract/nsis/winpath.cpp @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mupdf-source/thirdparty/tesseract/nsis/winpath.cpp	Mon Sep 15 11:43:07 2025 +0200
@@ -0,0 +1,39 @@
+// Copyright (C) 2024 Stefan Weil
+//
+// SPDX-License-Identifier: Apache-2.0
+//
+// winpath - run a Windows program with extended PATH
+//
+// Usage:
+//
+//     winpath [CMD [ARGUMENT ...]]
+//
+// Example:
+//
+//     winpath cmd
+//
+// This will start a Windows command line with PATH extended by
+// the location of the winpath executable.
+
+#include <process.h>    // _spawnvp
+#include <stdlib.h>     // _putenv_s
+#include <string.h>     // strcpy, strcat
+
+static char path[4096];
+
+int main(int argc, char *argv[]) {
+  if (argc > 1) {
+    char *dir = argv[0];
+    char *last = strrchr(dir, '\\');
+    if (last != nullptr) {
+      *last = '\0';
+    }
+    strcpy(path, dir);
+    strcat(path, ";");
+    strcat(path, getenv("PATH"));
+    _putenv_s("PATH", path);
+    _spawnvp(_P_WAIT, argv[1], argv + 1);
+    //~ _spawnvp(_P_OVERLAY, argv[1], argv + 1);
+  }
+  return 0;
+}