source: trunk/testapp/console/fullpath/fullpath.c@ 21631

Last change on this file since 21631 was 21631, checked in by dmik, 14 years ago

minivcrt: Fixed _fullpath()/_wfullpath() which was broken in many regards (i.e. it would eat path components starting with "." and "..").

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1#include <stdio.h>
2#include <windows.h>
3#include <tchar.h>
4
5#ifndef _MSC_VER
6
7#include <odinlx.h>
8
9#include <minivcrt.h>
10
11int _main();
12int _argc;
13char **_argv;
14
15int WIN32API WinMain(HANDLE hInstance,
16 HANDLE hPrevInstance,
17 LPSTR lpCmdLine,
18 int nCmdShow)
19{
20 return _main(_argc, _argv);
21}
22
23int main(int argc, char **argv)
24{
25 _argc = argc;
26 _argv = argv;
27 EnableSEH();
28 RegisterLxExe(WinMain, NULL);
29}
30
31#else
32#define _main main
33#endif
34
35static void test_fullpath(const char *path)
36{
37 char fullPath[MAX_PATH];
38 _fullpath(fullPath, path, sizeof(fullPath));
39 printf("### [%s] => [%s]\n", path, fullPath);
40}
41
42static void do_test_fullpath()
43{
44 test_fullpath("");
45 test_fullpath("\\");
46 test_fullpath("\\\\\\\\");
47 test_fullpath(".");
48 test_fullpath(".\\");
49 test_fullpath("\\.");
50 test_fullpath("\\.\\");
51 test_fullpath("..");
52 test_fullpath("..\\");
53 test_fullpath("\\..");
54 test_fullpath("\\..\\");
55 test_fullpath("a\\b");
56 test_fullpath("\\a\\b");
57 test_fullpath("a\\b\\");
58 test_fullpath("\\a\\b\\");
59 test_fullpath("d:\\a\\b");
60 test_fullpath("d:\\a\\b\\");
61 test_fullpath("d:\\a\\b\\\\");
62 test_fullpath("d:\\a\\\\b\\c\\\\d");
63 test_fullpath("d:\\a\\.\\.\\b\\c\\.\\.\\.\\d");
64 test_fullpath("d:\\..\\..\\.\\");
65 test_fullpath("d:\\a\\\\b\\c\\\\d\\..\\e");
66 test_fullpath("d:\\a\\\\b\\c\\\\d\\..\\..\\e");
67 test_fullpath("d:\\a\\\\b\\c\\\\d\\..\\..\\..\\e");
68 test_fullpath("d:\\a\\\\b\\c\\\\d\\..\\..\\\\..\\e");
69 test_fullpath("d:\\a\\\\b\\c\\\\d\\..\\..\\..\\..\\e");
70 test_fullpath("d:\\a\\\\b\\c\\\\d\\..\\..\\..\\..\\..\\e");
71 test_fullpath("d\\a\\\\b\\c\\\\d\\..\\..\\..\\..\\..\\e");
72}
73
74int _main(int argc, char **argv)
75{
76 do_test_fullpath();
77
78 return 0;
79}
Note: See TracBrowser for help on using the repository browser.