Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/tesseract/nsis/winpath.cpp @ 3:2c135c81b16c
MERGE: upstream PyMuPDF 1.26.4 with MuPDF 1.26.7
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:44:09 +0200 |
| parents | b50eed0cc0ef |
| children |
comparison
equal
deleted
inserted
replaced
| 0:6015a75abc2d | 3:2c135c81b16c |
|---|---|
| 1 // Copyright (C) 2024 Stefan Weil | |
| 2 // | |
| 3 // SPDX-License-Identifier: Apache-2.0 | |
| 4 // | |
| 5 // winpath - run a Windows program with extended PATH | |
| 6 // | |
| 7 // Usage: | |
| 8 // | |
| 9 // winpath [CMD [ARGUMENT ...]] | |
| 10 // | |
| 11 // Example: | |
| 12 // | |
| 13 // winpath cmd | |
| 14 // | |
| 15 // This will start a Windows command line with PATH extended by | |
| 16 // the location of the winpath executable. | |
| 17 | |
| 18 #include <process.h> // _spawnvp | |
| 19 #include <stdlib.h> // _putenv_s | |
| 20 #include <string.h> // strcpy, strcat | |
| 21 | |
| 22 static char path[4096]; | |
| 23 | |
| 24 int main(int argc, char *argv[]) { | |
| 25 if (argc > 1) { | |
| 26 char *dir = argv[0]; | |
| 27 char *last = strrchr(dir, '\\'); | |
| 28 if (last != nullptr) { | |
| 29 *last = '\0'; | |
| 30 } | |
| 31 strcpy(path, dir); | |
| 32 strcat(path, ";"); | |
| 33 strcat(path, getenv("PATH")); | |
| 34 _putenv_s("PATH", path); | |
| 35 _spawnvp(_P_WAIT, argv[1], argv + 1); | |
| 36 //~ _spawnvp(_P_OVERLAY, argv[1], argv + 1); | |
| 37 } | |
| 38 return 0; | |
| 39 } |
