2 * Copyright (C) 2005 Stefan Leichter
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/test.h"
28 static void test_find_file(void)
32 char appdir
[MAX_PATH
];
33 char curdir
[MAX_PATH
];
34 char filename
[MAX_PATH
];
35 char outBuf
[MAX_PATH
];
36 char windir
[MAX_PATH
];
38 memset(appdir
, 0, MAX_PATH
);
39 memset(windir
, 0, MAX_PATH
);
43 memset(curdir
, 0, MAX_PATH
);
44 memset(outBuf
, 0, MAX_PATH
);
45 ret
= VerFindFileA(0, "regedit", "", "", curdir
, &dwCur
, outBuf
, &dwOut
);
48 ok(dwCur
== 1, "Wrong length of buffer for current location: "
49 "got %d(%s) expected 1\n", dwCur
, curdir
);
50 ok(dwOut
== 1, "Wrong length of buffer for the recommended installation location: "
51 "got %d(%s) expected 1\n", dwOut
, outBuf
);
53 case VFF_BUFFTOOSMALL
:
54 ok(dwCur
== MAX_PATH
, "Wrong length of buffer for current location: "
55 "got %d(%s) expected MAX_PATH\n", dwCur
, curdir
);
56 ok(dwOut
== MAX_PATH
, "Wrong length of buffer for the recommended installation location: "
57 "got %d(%s) expected MAX_PATH\n", dwOut
, outBuf
);
60 ok(0, "Got unexpected return value %lx\n", ret
);
63 if(!GetWindowsDirectoryA(windir
, MAX_PATH
))
64 trace("GetWindowsDirectoryA failed\n");
66 sprintf(appdir
, "%s\\regedit.exe", windir
);
67 if(INVALID_FILE_ATTRIBUTES
== GetFileAttributesA(appdir
))
68 trace("GetFileAttributesA(%s) failed\n", appdir
);
72 memset(curdir
, 0, MAX_PATH
);
73 memset(outBuf
, 0, MAX_PATH
);
74 ret
= VerFindFileA(0, "regedit.exe", "", "", curdir
, &dwCur
, outBuf
, &dwOut
);
77 ok(dwCur
== 1 + strlen(windir
), "Wrong length of buffer for current location: "
78 "got %d(%s) expected %d\n", dwCur
, curdir
, lstrlenA(windir
)+1);
79 ok(dwOut
== 1, "Wrong length of buffer for the recommended installation location: "
80 "got %d(%s) expected 1\n", dwOut
, outBuf
);
82 case VFF_BUFFTOOSMALL
:
83 ok(dwCur
== MAX_PATH
, "Wrong length of buffer for current location: "
84 "got %d(%s) expected MAX_PATH\n", dwCur
, curdir
);
85 ok(dwOut
== MAX_PATH
, "Wrong length of buffer for the recommended installation location: "
86 "got %d(%s) expected MAX_PATH\n", dwOut
, outBuf
);
89 todo_wine
ok(0, "Got unexpected return value %lx\n", ret
);
94 memset(curdir
, 0, MAX_PATH
);
95 memset(outBuf
, 0, MAX_PATH
);
96 ret
= VerFindFileA(0, "regedit.exe", NULL
, NULL
, curdir
, &dwCur
, outBuf
, &dwOut
);
99 ok(dwCur
== 1 + strlen(windir
), "Wrong length of buffer for current location: "
100 "got %d(%s) expected %d\n", dwCur
, curdir
, lstrlenA(windir
)+1);
101 ok(dwOut
== 1, "Wrong length of buffer for the recommended installation location: "
102 "got %d(%s) expected 1\n", dwOut
, outBuf
);
104 case VFF_BUFFTOOSMALL
:
105 ok(dwCur
== MAX_PATH
, "Wrong length of buffer for current location: "
106 "got %d(%s) expected MAX_PATH\n", dwCur
, curdir
);
107 ok(dwOut
== MAX_PATH
, "Wrong length of buffer for the recommended installation location: "
108 "got %d(%s) expected MAX_PATH\n", dwOut
, outBuf
);
111 todo_wine
ok(0, "Got unexpected return value %lx\n", ret
);
115 if(!GetModuleFileNameA(NULL
, filename
, MAX_PATH
) ||
116 !GetSystemDirectoryA(windir
, MAX_PATH
) ||
117 !GetTempPathA(MAX_PATH
, appdir
))
118 trace("GetModuleFileNameA, GetSystemDirectoryA or GetTempPathA failed\n");
120 char *p
= strrchr(filename
, '\\');
123 SetCurrentDirectoryA(filename
);
124 memmove(filename
, p
, 1 + strlen(p
));
129 memset(outBuf
, 0, MAX_PATH
);
130 memset(curdir
, 0, MAX_PATH
);
131 ret
= VerFindFileA(0, filename
, NULL
, NULL
, curdir
, &dwCur
, outBuf
, &dwOut
);
134 ok(dwOut
== 1, "Wrong length of buffer for the recommended installation location"
135 "got %d(%s) expected 1\n", dwOut
, outBuf
);
137 case VFF_BUFFTOOSMALL
:
138 ok(dwOut
== MAX_PATH
, "Wrong length of buffer for the recommended installation location"
139 "got %d(%s) expected MAX_PATH\n", dwOut
, outBuf
);
142 todo_wine
ok(0, "Got unexpected return value %lx\n", ret
);
147 memset(outBuf
, 0, MAX_PATH
);
148 memset(curdir
, 0, MAX_PATH
);
149 ret
= VerFindFileA(VFFF_ISSHAREDFILE
, filename
, NULL
, appdir
, curdir
, &dwCur
, outBuf
, &dwOut
);
150 todo_wine
ok(VFF_CURNEDEST
== ret
, "Wrong return value got %lx expected VFF_CURNEDEST\n", ret
);
151 ok(dwOut
== 1 + strlen(windir
), "Wrong length of buffer for current location: "
152 "got %d(%s) expected %d\n", dwOut
, outBuf
, lstrlenA(windir
)+1);
156 memset(outBuf
, 0, MAX_PATH
);
157 memset(curdir
, 0, MAX_PATH
);
158 ret
= VerFindFileA(0, filename
, NULL
, appdir
, curdir
, &dwCur
, outBuf
, &dwOut
);
159 todo_wine
ok(VFF_CURNEDEST
== ret
, "Wrong return value got %lx expected VFF_CURNEDEST\n", ret
);
160 ok(dwOut
== 1 + strlen(appdir
), "Wrong length of buffer for current location: "
161 "got %d(%s) expected %d\n", dwOut
, outBuf
, lstrlenA(appdir
)+1);