File: maxima_longnames.c

package info (click to toggle)
maxima 5.47.0-9
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 193,104 kB
  • sloc: lisp: 434,678; fortran: 14,665; tcl: 10,990; sh: 4,577; makefile: 2,763; ansic: 447; java: 328; python: 262; perl: 201; xml: 60; awk: 28; sed: 15; javascript: 2
file content (47 lines) | stat: -rw-r--r-- 1,340 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
SPDX-License-Identifier: GPL-2.0-or-later
    Clisp has problems with generated Windows 'short names' e.g.
    echo %TMP%
    C:\Users\TESTTE~1\AppData\Local\Temp
    Windows generates a short name for the temporary dir, when the
    username contains spaces and is longer than 8 chars.
    This program converts that path name to the 'long version', so that Clisp has
    no problems with long user names and plotting commands.
*/
#include <windows.h>
#include <tchar.h>
#include <stdio.h>

#define BUFSIZE 4096

int main(int argc, char *argv[])
{
    DWORD  retval=0;
    TCHAR  buffer[BUFSIZE];

   if( argc != 2 )
   {
      _tprintf(TEXT("Usage: maxima_longnames [filename]\n\n"));
      _tprintf(TEXT("This program converts Windows generated short filenames (ending with \"~\"\n"));
      _tprintf(TEXT("and a number (8.3 format for compatibility with old Windows/DOS versions))\n"));
      _tprintf(TEXT("back to the long filename (The short name cause problems with CLISP.)\n"));
      return 1;
   }

// Retrieve the long path name.  

    retval = GetLongPathName(argv[1],
              buffer,
              BUFSIZE);

    if (retval == 0) 
    {
        // Handle an error condition.
         printf ("GetLongPathName failed (%d)\n", GetLastError());
         return 1;
    }
    else printf("%s", buffer);
    return 0;
}