Translated if now honors prederror
[maxima.git] / crosscompile-windows / maxima_longnames.c
blob8c08a1559a7ce4f0c73b6c4c9ea3bb750e5ba359
1 /*
2 SPDX-License-Identifier: GPL-2.0-or-later
3 Clisp has problems with generated Windows 'short names' e.g.
4 echo %TMP%
5 C:\Users\TESTTE~1\AppData\Local\Temp
6 Windows generates a short name for the temporary dir, when the
7 username contains spaces and is longer than 8 chars.
8 This program converts that path name to the 'long version', so that Clisp has
9 no problems with long user names and plotting commands.
11 #include <windows.h>
12 #include <tchar.h>
13 #include <stdio.h>
15 #define BUFSIZE 4096
17 int main(int argc, char *argv[])
19 DWORD retval=0;
20 TCHAR buffer[BUFSIZE];
22 if( argc != 2 )
24 _tprintf(TEXT("Usage: maxima_longnames [filename]\n\n"));
25 _tprintf(TEXT("This program converts Windows generated short filenames (ending with \"~\"\n"));
26 _tprintf(TEXT("and a number (8.3 format for compatibility with old Windows/DOS versions))\n"));
27 _tprintf(TEXT("back to the long filename (The short name cause problems with CLISP.)\n"));
28 return 1;
31 // Retrieve the long path name.
33 retval = GetLongPathName(argv[1],
34 buffer,
35 BUFSIZE);
37 if (retval == 0)
39 // Handle an error condition.
40 printf ("GetLongPathName failed (%d)\n", GetLastError());
41 return 1;
43 else printf("%s", buffer);
44 return 0;