first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / core / tools / simple_utilities / short_path.cpp
1 /*****************************************************************************\
2 *                                                                             *
3 *  Name   : short_path                                                        *
4 *  Author : Chris Koeritz                                                     *
5 *                                                                             *
6 *  Purpose:                                                                   *
7 *                                                                             *
8 *    This program converts a pathname to its 8.3 name.  Only for windows.     *
9 *                                                                             *
10 *******************************************************************************
11 * Copyright (c) 2007-$now By Author.  This program is free software; you can  *
12 * redistribute it and/or modify it under the terms of the GNU General Public  *
13 * License as published by the Free Software Foundation; either version 2 of   *
14 * the License or (at your option) any later version.  This is online at:      *
15 *     http://www.fsf.org/copyleft/gpl.html                                    *
16 * Please send any updates to: fred@gruntose.com                               *
17 \*****************************************************************************/
18
19 #include <application/windoze_helper.h>
20 #include <basis/astring.h>
21 #include <structures/static_memory_gremlin.h>
22
23 #include <stdio.h>
24 #include <string.h>
25 #ifdef __WIN32__
26   #include <windows.h>
27 #endif
28
29 using namespace basis;
30 using namespace structures;
31
32 ///HOOPLE_STARTUP_CODE;
33
34 int main(int argc, char *argv[])
35 {
36   astring shorty('\0', 2048);
37   if (argc < 2) {
38     printf("This program needs a path to convert to its short form.\n");
39     return 23;
40   }
41 #ifdef __WIN32__
42   GetShortPathNameA(argv[1], shorty.s(), 2045);
43 #else
44   strcpy(shorty.s(), argv[1]);
45 #endif
46   shorty.replace_all('\\', '/');
47   printf("%s", shorty.s());
48   return 0;
49 }
50
51 #ifdef __BUILD_STATIC_APPLICATION__
52   // static dependencies found by buildor_gen_deps.sh:
53   #include <basis/astring.cpp>
54   #include <basis/common_outcomes.cpp>
55   #include <basis/mutex.cpp>
56   #include <structures/static_memory_gremlin.cpp>
57 #endif // __BUILD_STATIC_APPLICATION__
58