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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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
);
46 ok(!ret
, "Wrong return value got %lx expected 0\n", ret
);
47 ok(dwCur
== 1, "Wrong length of buffer for current location: "
48 "got %d(%s) expected 1\n", dwCur
, curdir
);
49 ok(dwOut
== 1, "Wrong length of buffer for the recommended installation location: "
50 "got %d(%s) expected 1\n", dwOut
, outBuf
);
52 if(!GetWindowsDirectoryA(windir
, MAX_PATH
))
53 trace("GetWindowsDirectoryA failed\n");
55 sprintf(appdir
, "%s\\regedit.exe", windir
);
56 if(INVALID_FILE_ATTRIBUTES
== GetFileAttributesA(appdir
))
57 trace("GetFileAttributesA(%s) failed\n", appdir
);
61 memset(curdir
, 0, MAX_PATH
);
62 memset(outBuf
, 0, MAX_PATH
);
63 ret
= VerFindFileA(0, "regedit.exe", "", "", curdir
, &dwCur
, outBuf
, &dwOut
);
64 todo_wine
ok(VFF_CURNEDEST
== ret
, "Wrong return value got %lx expected VFF_CURNEDEST\n", ret
);
65 todo_wine
ok(dwCur
== 1 + strlen(windir
), "Wrong length of buffer for current location: "
66 "got %d(%s) expected %d\n", dwCur
, curdir
, strlen(windir
)+1);
67 ok(dwOut
== 1, "Wrong length of buffer for the recommended installation location: "
68 "got %d(%s) expected 1\n", dwOut
, outBuf
);
72 memset(curdir
, 0, MAX_PATH
);
73 memset(outBuf
, 0, MAX_PATH
);
74 ret
= VerFindFileA(0, "regedit.exe", NULL
, NULL
, curdir
, &dwCur
, outBuf
, &dwOut
);
75 todo_wine
ok(VFF_CURNEDEST
== ret
, "Wrong return value got %lx expected VFF_CURNEDEST\n", ret
);
76 todo_wine
ok(dwCur
== 1 + strlen(windir
), "Wrong length of buffer for current location: "
77 "got %d(%s) expected %d\n", dwCur
, curdir
, strlen(windir
)+1);
78 ok(dwOut
== 1, "Wrong length of buffer for the recommended installation location: "
79 "got %d(%s) expected 1\n", dwOut
, outBuf
);
82 if(!GetModuleFileNameA(NULL
, filename
, MAX_PATH
) ||
83 !GetSystemDirectoryA(windir
, MAX_PATH
) ||
84 !GetTempPathA(MAX_PATH
, appdir
))
85 trace("GetModuleFileNameA, GetSystemDirectoryA or GetTempPathA failed\n");
87 char *p
= strrchr(filename
, '\\');
90 SetCurrentDirectoryA(filename
);
91 memmove(filename
, p
, 1 + strlen(p
));
96 memset(outBuf
, 0, MAX_PATH
);
97 memset(curdir
, 0, MAX_PATH
);
98 ret
= VerFindFileA(0, filename
, NULL
, NULL
, curdir
, &dwCur
, outBuf
, &dwOut
);
99 todo_wine
ok(VFF_CURNEDEST
== ret
, "Wrong return value got %lx expected VFF_CURNEDEST\n", ret
);
100 ok(dwOut
== 1, "Wrong length of buffer for the recommended installation location"
101 "got %d(%s) expected 1\n", dwOut
, outBuf
);
105 memset(outBuf
, 0, MAX_PATH
);
106 memset(curdir
, 0, MAX_PATH
);
107 ret
= VerFindFileA(VFFF_ISSHAREDFILE
, filename
, NULL
, appdir
, curdir
, &dwCur
, outBuf
, &dwOut
);
108 todo_wine
ok(VFF_CURNEDEST
== ret
, "Wrong return value got %lx expected VFF_CURNEDEST\n", ret
);
109 ok(dwOut
== 1 + strlen(windir
), "Wrong length of buffer for current location: "
110 "got %d(%s) expected %d\n", dwOut
, outBuf
, strlen(windir
)+1);
114 memset(outBuf
, 0, MAX_PATH
);
115 memset(curdir
, 0, MAX_PATH
);
116 ret
= VerFindFileA(0, filename
, NULL
, appdir
, curdir
, &dwCur
, outBuf
, &dwOut
);
117 todo_wine
ok(VFF_CURNEDEST
== ret
, "Wrong return value got %lx expected VFF_CURNEDEST\n", ret
);
118 ok(dwOut
== 1 + strlen(appdir
), "Wrong length of buffer for current location: "
119 "got %d(%s) expected %d\n", dwOut
, outBuf
, strlen(appdir
)+1);