Reimplemented DeleteFile by using CreateFile with
[wine/testsucceed.git] / dlls / kernel / tests / file.c
blob88fc271099cb3d71d139d87a0d5bd2822a1f0b98
1 /*
2 * Unit tests for file functions in Wine
4 * Copyright (c) 2002 Jakob Eriksson
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <stdarg.h>
23 #include <stdlib.h>
24 #include <time.h>
26 #include "wine/test.h"
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winerror.h"
31 LPCSTR filename = "testfile.xxx";
32 LPCSTR sillytext =
33 "en larvig liten text dx \033 gx hej 84 hej 4484 ! \001\033 bla bl\na.. bla bla."
34 "1234 43 4kljf lf &%%%&&&&&& 34 4 34 3############# 33 3 3 3 # 3## 3"
35 "1234 43 4kljf lf &%%%&&&&&& 34 4 34 3############# 33 3 3 3 # 3## 3"
36 "1234 43 4kljf lf &%%%&&&&&& 34 4 34 3############# 33 3 3 3 # 3## 3"
37 "1234 43 4kljf lf &%%%&&&&&& 34 4 34 3############# 33 3 3 3 # 3## 3"
38 "1234 43 4kljf lf &%%%&&&&&& 34 4 34 3############# 33 3 3 3 # 3## 3"
39 "1234 43 4kljf lf &%%%&&&&&& 34 4 34 3############# 33 3 3 3 # 3## 3"
40 "1234 43 4kljf lf &%%%&&&&&& 34 4 34 3############# 33 3 3 3 # 3## 3"
41 "1234 43 4kljf lf &%%%&&&&&& 34 4 34 3############# 33 3 3 3 # 3## 3"
42 "sdlkfjasdlkfj a dslkj adsklf \n \nasdklf askldfa sdlkf \nsadklf asdklf asdf ";
45 static void test__hread( void )
47 HFILE filehandle;
48 char buffer[10000];
49 long bytes_read;
50 long bytes_wanted;
51 long i;
53 SetFileAttributesA(filename,FILE_ATTRIBUTE_NORMAL); /* be sure to remove stale files */
54 DeleteFileA( filename );
55 filehandle = _lcreat( filename, 0 );
56 if (filehandle == HFILE_ERROR)
58 ok(0,"couldn't create file \"%s\" (err=%ld)\n",filename,GetLastError());
59 return;
62 ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite complains\n" );
64 ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" );
66 filehandle = _lopen( filename, OF_READ );
68 ok( HFILE_ERROR != filehandle, "couldn't open file \"%s\" again (err=%ld)\n", filename, GetLastError( ) );
70 bytes_read = _hread( filehandle, buffer, 2 * strlen( sillytext ) );
72 ok( lstrlenA( sillytext ) == bytes_read, "file read size error\n" );
74 for (bytes_wanted = 0; bytes_wanted < lstrlenA( sillytext ); bytes_wanted++)
76 ok( 0 == _llseek( filehandle, 0, FILE_BEGIN ), "_llseek complains\n" );
77 ok( _hread( filehandle, buffer, bytes_wanted ) == bytes_wanted, "erratic _hread return value\n" );
78 for (i = 0; i < bytes_wanted; i++)
80 ok( buffer[i] == sillytext[i], "that's not what's written\n" );
84 ok( HFILE_ERROR != _lclose( filehandle ), "_lclose complains\n" );
86 ok( DeleteFileA( filename ) != 0, "DeleteFile failed (%ld)\n", GetLastError( ) );
90 static void test__hwrite( void )
92 HFILE filehandle;
93 char buffer[10000];
94 long bytes_read;
95 long bytes_written;
96 long blocks;
97 long i;
98 char *contents;
99 HLOCAL memory_object;
100 char checksum[1];
102 filehandle = _lcreat( filename, 0 );
103 if (filehandle == HFILE_ERROR)
105 ok(0,"couldn't create file \"%s\" (err=%ld)\n",filename,GetLastError());
106 return;
109 ok( HFILE_ERROR != _hwrite( filehandle, "", 0 ), "_hwrite complains\n" );
111 ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" );
113 filehandle = _lopen( filename, OF_READ );
115 bytes_read = _hread( filehandle, buffer, 1);
117 ok( 0 == bytes_read, "file read size error\n" );
119 ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" );
121 filehandle = _lopen( filename, OF_READWRITE );
123 bytes_written = 0;
124 checksum[0] = '\0';
125 srand( (unsigned)time( NULL ) );
126 for (blocks = 0; blocks < 100; blocks++)
128 for (i = 0; i < (long)sizeof( buffer ); i++)
130 buffer[i] = rand( );
131 checksum[0] = checksum[0] + buffer[i];
133 ok( HFILE_ERROR != _hwrite( filehandle, buffer, sizeof( buffer ) ), "_hwrite complains\n" );
134 bytes_written = bytes_written + sizeof( buffer );
137 ok( HFILE_ERROR != _hwrite( filehandle, checksum, 1 ), "_hwrite complains\n" );
138 bytes_written++;
140 ok( HFILE_ERROR != _lclose( filehandle ), "_lclose complains\n" );
142 memory_object = LocalAlloc( LPTR, bytes_written );
144 ok( 0 != memory_object, "LocalAlloc fails. (Could be out of memory.)\n" );
146 contents = LocalLock( memory_object );
148 filehandle = _lopen( filename, OF_READ );
150 contents = LocalLock( memory_object );
152 ok( NULL != contents, "LocalLock whines\n" );
154 ok( bytes_written == _hread( filehandle, contents, bytes_written), "read length differ from write length\n" );
156 checksum[0] = '\0';
157 i = 0;
160 checksum[0] = checksum[0] + contents[i];
161 i++;
163 while (i < bytes_written - 1);
165 ok( checksum[0] == contents[i], "stored checksum differ from computed checksum\n" );
167 ok( HFILE_ERROR != _lclose( filehandle ), "_lclose complains\n" );
169 ok( DeleteFileA( filename ) != 0, "DeleteFile failed (%ld)\n", GetLastError( ) );
173 static void test__lclose( void )
175 HFILE filehandle;
177 filehandle = _lcreat( filename, 0 );
178 if (filehandle == HFILE_ERROR)
180 ok(0,"couldn't create file \"%s\" (err=%ld)\n",filename,GetLastError());
181 return;
184 ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite complains\n" );
186 ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" );
188 ok( DeleteFileA( filename ) != 0, "DeleteFile failed (%ld)\n", GetLastError( ) );
192 static void test__lcreat( void )
194 HFILE filehandle;
195 char buffer[10000];
196 WIN32_FIND_DATAA search_results;
197 char slashname[] = "testfi/";
198 int err;
199 HANDLE find;
201 filehandle = _lcreat( filename, 0 );
202 if (filehandle == HFILE_ERROR)
204 ok(0,"couldn't create file \"%s\" (err=%ld)\n",filename,GetLastError());
205 return;
208 ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite complains\n" );
210 ok( 0 == _llseek( filehandle, 0, FILE_BEGIN ), "_llseek complains\n" );
212 ok( _hread( filehandle, buffer, strlen( sillytext ) ) == lstrlenA( sillytext ), "erratic _hread return value\n" );
214 ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" );
216 ok( INVALID_HANDLE_VALUE != FindFirstFileA( filename, &search_results ), "should be able to find file\n" );
218 ok( DeleteFileA(filename) != 0, "DeleteFile failed (%ld)\n", GetLastError());
220 filehandle = _lcreat( filename, 1 ); /* readonly */
221 ok( HFILE_ERROR != filehandle, "couldn't create file \"%s\" (err=%ld)\n", filename, GetLastError( ) );
223 ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite shouldn't be able to write never the less\n" );
225 ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" );
227 ok( INVALID_HANDLE_VALUE != FindFirstFileA( filename, &search_results ), "should be able to find file\n" );
229 ok( 0 == DeleteFileA( filename ), "shouldn't be able to delete a readonly file\n" );
231 ok( SetFileAttributesA(filename, FILE_ATTRIBUTE_NORMAL ) != 0, "couldn't change attributes on file\n" );
233 ok( DeleteFileA( filename ) != 0, "now it should be possible to delete the file!\n" );
235 filehandle = _lcreat( filename, 2 );
236 ok( HFILE_ERROR != filehandle, "couldn't create file \"%s\" (err=%ld)\n", filename, GetLastError( ) );
238 ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite complains\n" );
240 ok( 0 == _llseek( filehandle, 0, FILE_BEGIN ), "_llseek complains\n" );
242 ok( _hread( filehandle, buffer, strlen( sillytext ) ) == lstrlenA( sillytext ), "erratic _hread return value\n" );
244 ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" );
246 ok( INVALID_HANDLE_VALUE != FindFirstFileA( filename, &search_results ), "should STILL be able to find file\n" );
248 ok( DeleteFileA( filename ) != 0, "DeleteFile failed (%ld)\n", GetLastError( ) );
250 filehandle = _lcreat( filename, 4 ); /* SYSTEM file */
251 ok( HFILE_ERROR != filehandle, "couldn't create file \"%s\" (err=%ld)\n", filename, GetLastError( ) );
253 ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite complains\n" );
255 ok( 0 == _llseek( filehandle, 0, FILE_BEGIN ), "_llseek complains\n" );
257 ok( _hread( filehandle, buffer, strlen( sillytext ) ) == lstrlenA( sillytext ), "erratic _hread return value\n" );
259 ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" );
261 ok( INVALID_HANDLE_VALUE != FindFirstFileA( filename, &search_results ), "should STILL be able to find file\n" );
263 ok( DeleteFileA( filename ) != 0, "DeleteFile failed (%ld)\n", GetLastError( ) );
265 filehandle=_lcreat (slashname, 0); /* illegal name */
266 if (HFILE_ERROR==filehandle) {
267 err=GetLastError ();
268 ok (err==ERROR_INVALID_NAME || err==ERROR_PATH_NOT_FOUND,
269 "creating file \"%s\" failed with error %d\n", slashname, err);
270 } else { /* only NT succeeds */
271 _lclose(filehandle);
272 find=FindFirstFileA (slashname, &search_results);
273 if (INVALID_HANDLE_VALUE!=find)
275 ok (0!=FindClose (find), "FindClose complains (%ld)\n", GetLastError ());
276 slashname[strlen(slashname)-1]=0;
277 ok (!strcmp (slashname, search_results.cFileName),
278 "found unexpected name \"%s\"\n", search_results.cFileName);
279 ok (FILE_ATTRIBUTE_ARCHIVE==search_results.dwFileAttributes,
280 "attributes of file \"%s\" are 0x%04lx\n", search_results.cFileName,
281 search_results.dwFileAttributes);
283 ok (0!=DeleteFileA (slashname), "Can't delete \"%s\" (%ld)\n", slashname,
284 GetLastError ());
287 filehandle=_lcreat (filename, 8); /* illegal attribute */
288 if (HFILE_ERROR==filehandle)
289 ok (0, "couldn't create volume label \"%s\"\n", filename);
290 else {
291 _lclose(filehandle);
292 find=FindFirstFileA (filename, &search_results);
293 if (INVALID_HANDLE_VALUE==find)
294 ok (0, "file \"%s\" not found\n", filename);
295 else {
296 ok (0!=FindClose (find), "FindClose complains (%ld)\n", GetLastError ());
297 ok (!strcmp (filename, search_results.cFileName),
298 "found unexpected name \"%s\"\n", search_results.cFileName);
299 ok (FILE_ATTRIBUTE_ARCHIVE==search_results.dwFileAttributes,
300 "attributes of file \"%s\" are 0x%04lx\n", search_results.cFileName,
301 search_results.dwFileAttributes);
303 ok (0!=DeleteFileA (filename), "Can't delete \"%s\" (%ld)\n", slashname,
304 GetLastError ());
309 static void test__llseek( void )
311 INT i;
312 HFILE filehandle;
313 char buffer[1];
314 long bytes_read;
316 filehandle = _lcreat( filename, 0 );
317 if (filehandle == HFILE_ERROR)
319 ok(0,"couldn't create file \"%s\" (err=%ld)\n",filename,GetLastError());
320 return;
323 for (i = 0; i < 400; i++)
325 ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite complains\n" );
327 ok( HFILE_ERROR != _llseek( filehandle, 400 * strlen( sillytext ), FILE_CURRENT ), "should be able to seek\n" );
328 ok( HFILE_ERROR != _llseek( filehandle, 27 + 35 * strlen( sillytext ), FILE_BEGIN ), "should be able to seek\n" );
330 bytes_read = _hread( filehandle, buffer, 1);
331 ok( 1 == bytes_read, "file read size error\n" );
332 ok( buffer[0] == sillytext[27], "_llseek error, it got lost seeking\n" );
333 ok( HFILE_ERROR != _llseek( filehandle, -400 * strlen( sillytext ), FILE_END ), "should be able to seek\n" );
335 bytes_read = _hread( filehandle, buffer, 1);
336 ok( 1 == bytes_read, "file read size error\n" );
337 ok( buffer[0] == sillytext[0], "_llseek error, it got lost seeking\n" );
338 ok( HFILE_ERROR != _llseek( filehandle, 1000000, FILE_END ), "should be able to seek past file; poor, poor Windows programmers\n" );
339 ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" );
341 ok( DeleteFileA( filename ) != 0, "DeleteFile failed (%ld)\n", GetLastError( ) );
345 static void test__llopen( void )
347 HFILE filehandle;
348 UINT bytes_read;
349 char buffer[10000];
351 filehandle = _lcreat( filename, 0 );
352 if (filehandle == HFILE_ERROR)
354 ok(0,"couldn't create file \"%s\" (err=%ld)\n",filename,GetLastError());
355 return;
358 ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite complains\n" );
359 ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" );
361 filehandle = _lopen( filename, OF_READ );
362 ok( HFILE_ERROR == _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite shouldn't be able to write!\n" );
363 bytes_read = _hread( filehandle, buffer, strlen( sillytext ) );
364 ok( strlen( sillytext ) == bytes_read, "file read size error\n" );
365 ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" );
367 filehandle = _lopen( filename, OF_READWRITE );
368 bytes_read = _hread( filehandle, buffer, 2 * strlen( sillytext ) );
369 ok( strlen( sillytext ) == bytes_read, "file read size error\n" );
370 ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite should write just fine\n" );
371 ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" );
373 filehandle = _lopen( filename, OF_WRITE );
374 ok( HFILE_ERROR == _hread( filehandle, buffer, 1 ), "you should only be able to write this file\n" );
375 ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite should write just fine\n" );
376 ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" );
378 ok( DeleteFileA( filename ) != 0, "DeleteFile failed (%ld)\n", GetLastError( ) );
379 /* TODO - add tests for the SHARE modes - use two processes to pull this one off */
383 static void test__lread( void )
385 HFILE filehandle;
386 char buffer[10000];
387 long bytes_read;
388 UINT bytes_wanted;
389 UINT i;
391 filehandle = _lcreat( filename, 0 );
392 if (filehandle == HFILE_ERROR)
394 ok(0,"couldn't create file \"%s\" (err=%ld)\n",filename,GetLastError());
395 return;
398 ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite complains\n" );
400 ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" );
402 filehandle = _lopen( filename, OF_READ );
404 ok( HFILE_ERROR != filehandle, "couldn't open file \"%s\" again (err=%ld)\n", filename, GetLastError());
406 bytes_read = _lread( filehandle, buffer, 2 * strlen( sillytext ) );
408 ok( lstrlenA( sillytext ) == bytes_read, "file read size error\n" );
410 for (bytes_wanted = 0; bytes_wanted < strlen( sillytext ); bytes_wanted++)
412 ok( 0 == _llseek( filehandle, 0, FILE_BEGIN ), "_llseek complains\n" );
413 ok( _lread( filehandle, buffer, bytes_wanted ) == bytes_wanted, "erratic _hread return value\n" );
414 for (i = 0; i < bytes_wanted; i++)
416 ok( buffer[i] == sillytext[i], "that's not what's written\n" );
420 ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" );
422 ok( DeleteFileA( filename ) != 0, "DeleteFile failed (%ld)\n", GetLastError( ) );
426 static void test__lwrite( void )
428 HFILE filehandle;
429 char buffer[10000];
430 long bytes_read;
431 long bytes_written;
432 long blocks;
433 long i;
434 char *contents;
435 HLOCAL memory_object;
436 char checksum[1];
438 filehandle = _lcreat( filename, 0 );
439 if (filehandle == HFILE_ERROR)
441 ok(0,"couldn't create file \"%s\" (err=%ld)\n",filename,GetLastError());
442 return;
445 ok( HFILE_ERROR != _lwrite( filehandle, "", 0 ), "_hwrite complains\n" );
447 ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" );
449 filehandle = _lopen( filename, OF_READ );
451 bytes_read = _hread( filehandle, buffer, 1);
453 ok( 0 == bytes_read, "file read size error\n" );
455 ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" );
457 filehandle = _lopen( filename, OF_READWRITE );
459 bytes_written = 0;
460 checksum[0] = '\0';
461 srand( (unsigned)time( NULL ) );
462 for (blocks = 0; blocks < 100; blocks++)
464 for (i = 0; i < (long)sizeof( buffer ); i++)
466 buffer[i] = rand( );
467 checksum[0] = checksum[0] + buffer[i];
469 ok( HFILE_ERROR != _lwrite( filehandle, buffer, sizeof( buffer ) ), "_hwrite complains\n" );
470 bytes_written = bytes_written + sizeof( buffer );
473 ok( HFILE_ERROR != _lwrite( filehandle, checksum, 1 ), "_hwrite complains\n" );
474 bytes_written++;
476 ok( HFILE_ERROR != _lclose( filehandle ), "_lclose complains\n" );
478 memory_object = LocalAlloc( LPTR, bytes_written );
480 ok( 0 != memory_object, "LocalAlloc fails, could be out of memory\n" );
482 contents = LocalLock( memory_object );
484 filehandle = _lopen( filename, OF_READ );
486 contents = LocalLock( memory_object );
488 ok( NULL != contents, "LocalLock whines\n" );
490 ok( bytes_written == _hread( filehandle, contents, bytes_written), "read length differ from write length\n" );
492 checksum[0] = '\0';
493 i = 0;
496 checksum[0] += contents[i];
497 i++;
499 while (i < bytes_written - 1);
501 ok( checksum[0] == contents[i], "stored checksum differ from computed checksum\n" );
503 ok( HFILE_ERROR != _lclose( filehandle ), "_lclose complains\n" );
505 ok( DeleteFileA( filename ) != 0, "DeleteFile failed (%ld)\n", GetLastError( ) );
508 static void test_CopyFileA(void)
510 char temp_path[MAX_PATH];
511 char source[MAX_PATH], dest[MAX_PATH];
512 static const char prefix[] = "pfx";
513 DWORD ret;
515 ret = GetTempPathA(MAX_PATH, temp_path);
516 ok(ret != 0, "GetTempPathA error %ld\n", GetLastError());
517 ok(ret < MAX_PATH, "temp path should fit into MAX_PATH\n");
519 ret = GetTempFileNameA(temp_path, prefix, 0, source);
520 ok(ret != 0, "GetTempFileNameA error %ld\n", GetLastError());
522 ret = GetTempFileNameA(temp_path, prefix, 0, dest);
523 ok(ret != 0, "GetTempFileNameA error %ld\n", GetLastError());
525 ret = CopyFileA(source, dest, TRUE);
526 ok(!ret && GetLastError() == ERROR_FILE_EXISTS,
527 "CopyFileA: unexpected error %ld\n", GetLastError());
529 ret = CopyFileA(source, dest, FALSE);
530 ok(ret, "CopyFileA: error %ld\n", GetLastError());
532 ret = DeleteFileA(source);
533 ok(ret, "DeleteFileA: error %ld\n", GetLastError());
534 ret = DeleteFileA(dest);
535 ok(ret, "DeleteFileA: error %ld\n", GetLastError());
538 static void test_CopyFileW(void)
540 WCHAR temp_path[MAX_PATH];
541 WCHAR source[MAX_PATH], dest[MAX_PATH];
542 static const WCHAR prefix[] = {'p','f','x',0};
543 DWORD ret;
545 ret = GetTempPathW(MAX_PATH, temp_path);
546 if (ret==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
547 return;
548 ok(ret != 0, "GetTempPathW error %ld\n", GetLastError());
549 ok(ret < MAX_PATH, "temp path should fit into MAX_PATH\n");
551 ret = GetTempFileNameW(temp_path, prefix, 0, source);
552 ok(ret != 0, "GetTempFileNameW error %ld\n", GetLastError());
554 ret = GetTempFileNameW(temp_path, prefix, 0, dest);
555 ok(ret != 0, "GetTempFileNameW error %ld\n", GetLastError());
557 ret = CopyFileW(source, dest, TRUE);
558 ok(!ret && GetLastError() == ERROR_FILE_EXISTS,
559 "CopyFileW: unexpected error %ld\n", GetLastError());
561 ret = CopyFileW(source, dest, FALSE);
562 ok(ret, "CopyFileW: error %ld\n", GetLastError());
564 ret = DeleteFileW(source);
565 ok(ret, "DeleteFileW: error %ld\n", GetLastError());
566 ret = DeleteFileW(dest);
567 ok(ret, "DeleteFileW: error %ld\n", GetLastError());
570 static void test_CreateFileA(void)
572 HANDLE hFile;
573 char temp_path[MAX_PATH];
574 char filename[MAX_PATH];
575 static const char prefix[] = "pfx";
576 DWORD ret;
578 ret = GetTempPathA(MAX_PATH, temp_path);
579 ok(ret != 0, "GetTempPathA error %ld\n", GetLastError());
580 ok(ret < MAX_PATH, "temp path should fit into MAX_PATH\n");
582 ret = GetTempFileNameA(temp_path, prefix, 0, filename);
583 ok(ret != 0, "GetTempFileNameA error %ld\n", GetLastError());
585 hFile = CreateFileA(filename, GENERIC_READ, 0, NULL,
586 CREATE_NEW, FILE_FLAG_RANDOM_ACCESS, 0);
587 ok(hFile == INVALID_HANDLE_VALUE && GetLastError() == ERROR_FILE_EXISTS,
588 "CREATE_NEW should fail if file exists and last error value should be ERROR_FILE_EXISTS\n");
590 ret = DeleteFileA(filename);
591 ok(ret, "DeleteFileA: error %ld\n", GetLastError());
594 static void test_CreateFileW(void)
596 HANDLE hFile;
597 WCHAR temp_path[MAX_PATH];
598 WCHAR filename[MAX_PATH];
599 WCHAR emptyW[]={'\0'};
600 static const WCHAR prefix[] = {'p','f','x',0};
601 DWORD ret;
603 ret = GetTempPathW(MAX_PATH, temp_path);
604 if (ret==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
605 return;
606 ok(ret != 0, "GetTempPathW error %ld\n", GetLastError());
607 ok(ret < MAX_PATH, "temp path should fit into MAX_PATH\n");
609 ret = GetTempFileNameW(temp_path, prefix, 0, filename);
610 ok(ret != 0, "GetTempFileNameW error %ld\n", GetLastError());
612 hFile = CreateFileW(filename, GENERIC_READ, 0, NULL,
613 CREATE_NEW, FILE_FLAG_RANDOM_ACCESS, 0);
614 ok(hFile == INVALID_HANDLE_VALUE && GetLastError() == ERROR_FILE_EXISTS,
615 "CREATE_NEW should fail if file exists and last error value should be ERROR_FILE_EXISTS\n");
617 ret = DeleteFileW(filename);
618 ok(ret, "DeleteFileW: error %ld\n", GetLastError());
620 hFile = CreateFileW(NULL, GENERIC_READ, 0, NULL,
621 CREATE_NEW, FILE_FLAG_RANDOM_ACCESS, 0);
622 ok(hFile == INVALID_HANDLE_VALUE && GetLastError() == ERROR_PATH_NOT_FOUND,
623 "CreateFileW(NULL) returned ret=%p error=%ld\n",hFile,GetLastError());
625 hFile = CreateFileW(emptyW, GENERIC_READ, 0, NULL,
626 CREATE_NEW, FILE_FLAG_RANDOM_ACCESS, 0);
627 ok(hFile == INVALID_HANDLE_VALUE && GetLastError() == ERROR_PATH_NOT_FOUND,
628 "CreateFileW(\"\") returned ret=%p error=%ld\n",hFile,GetLastError());
632 static void test_GetTempFileNameA() {
633 UINT result;
634 char out[MAX_PATH];
635 char *expected = "c:\\windows\\abc2.tmp";
637 /* this test may depend on the config file settings */
638 result = GetTempFileNameA("C:", "abc", 1, out);
639 ok( result != 0, "GetTempFileNameA: error %ld\n", GetLastError() );
640 ok( ((out[0] == 'C') && (out[1] == ':')) && (out[2] == '\\'), "GetTempFileNameA: first three characters should be C:\\, string was actually %s\n", out );
642 result = GetTempFileNameA("c:\\windows\\", "abc", 2, out);
643 ok( result != 0, "GetTempFileNameA: error %ld\n", GetLastError() );
644 ok( lstrcmpiA( out, expected ) == 0, "GetTempFileNameA: Unexpected output \"%s\" vs \"%s\"\n", out, expected );
648 static void test_DeleteFileA( void )
650 BOOL ret;
652 ret = DeleteFileA(NULL);
653 ok(!ret && (GetLastError() == ERROR_INVALID_PARAMETER ||
654 GetLastError() == ERROR_PATH_NOT_FOUND),
655 "DeleteFileA(NULL) returned ret=%d error=%ld\n",ret,GetLastError());
657 ret = DeleteFileA("");
658 ok(!ret && (GetLastError() == ERROR_PATH_NOT_FOUND ||
659 GetLastError() == ERROR_BAD_PATHNAME),
660 "DeleteFileA(\"\") returned ret=%d error=%ld\n",ret,GetLastError());
662 ret = DeleteFileA("nul");
663 ok(!ret && (GetLastError() == ERROR_FILE_NOT_FOUND ||
664 GetLastError() == ERROR_INVALID_PARAMETER),
665 "DeleteFileA(\"nul\") returned ret=%d error=%ld\n",ret,GetLastError());
668 static void test_DeleteFileW( void )
670 BOOL ret;
671 WCHAR emptyW[]={'\0'};
673 ret = DeleteFileW(NULL);
674 if (ret==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
675 return;
676 ok(!ret && GetLastError() == ERROR_PATH_NOT_FOUND,
677 "DeleteFileW(NULL) returned ret=%d error=%ld\n",ret,GetLastError());
679 ret = DeleteFileW(emptyW);
680 ok(!ret && GetLastError() == ERROR_PATH_NOT_FOUND,
681 "DeleteFileW(\"\") returned ret=%d error=%ld\n",ret,GetLastError());
684 #define IsDotDir(x) ((x[0] == '.') && ((x[1] == 0) || ((x[1] == '.') && (x[2] == 0))))
686 static void test_MoveFileA(void)
688 char tempdir[MAX_PATH];
689 char source[MAX_PATH], dest[MAX_PATH];
690 static const char prefix[] = "pfx";
691 DWORD ret;
693 ret = GetTempPathA(MAX_PATH, tempdir);
694 ok(ret != 0, "GetTempPathA error %ld\n", GetLastError());
695 ok(ret < MAX_PATH, "temp path should fit into MAX_PATH\n");
697 ret = GetTempFileNameA(tempdir, prefix, 0, source);
698 ok(ret != 0, "GetTempFileNameA error %ld\n", GetLastError());
700 ret = GetTempFileNameA(tempdir, prefix, 0, dest);
701 ok(ret != 0, "GetTempFileNameA error %ld\n", GetLastError());
703 ret = MoveFileA(source, dest);
704 ok(!ret && GetLastError() == ERROR_ALREADY_EXISTS,
705 "MoveFileA: unexpected error %ld\n", GetLastError());
707 ret = DeleteFileA(dest);
708 ok(ret, "DeleteFileA: error %ld\n", GetLastError());
710 ret = MoveFileA(source, dest);
711 ok(ret, "MoveFileA: failed, error %ld\n", GetLastError());
713 lstrcatA(tempdir, "Remove Me");
714 ret = CreateDirectoryA(tempdir, NULL);
715 ok(ret == TRUE, "CreateDirectoryA failed\n");
717 lstrcpyA(source, dest);
718 lstrcpyA(dest, tempdir);
719 lstrcatA(dest, "\\wild?.*");
720 /* FIXME: if we create a file with wildcards we can't delete it now that DeleteFile works correctly */
721 #if 0
722 ret = MoveFileA(source, dest);
723 todo_wine {
724 ok(!ret, "MoveFileA: shouldn't move to wildcard file\n");
725 ok(GetLastError() == ERROR_INVALID_NAME,
726 "MoveFileA: with wildcards, unexpected error %ld\n", GetLastError());
727 if (ret || (GetLastError() != ERROR_INVALID_NAME))
729 WIN32_FIND_DATAA fd;
730 char temppath[MAX_PATH];
731 HANDLE hFind;
733 lstrcpyA(temppath, tempdir);
734 lstrcatA(temppath, "\\*.*");
735 hFind = FindFirstFileA(temppath, &fd);
736 if (INVALID_HANDLE_VALUE != hFind)
738 LPSTR lpName;
741 lpName = fd.cAlternateFileName;
742 if (!lpName[0])
743 lpName = fd.cFileName;
744 ok(IsDotDir(lpName), "MoveFileA: wildcards file created!\n");
746 while (FindNextFileA(hFind, &fd));
747 FindClose(hFind);
750 ret = DeleteFileA(source);
751 ok(ret, "DeleteFileA: error %ld\n", GetLastError());
752 ret = DeleteFileA(dest);
753 ok(!ret, "DeleteFileA: error %ld\n", GetLastError());
755 #endif
757 ret = RemoveDirectoryA(tempdir);
758 ok(ret, "DeleteDirectoryA: error %ld\n", GetLastError());
761 static void test_MoveFileW(void)
763 WCHAR temp_path[MAX_PATH];
764 WCHAR source[MAX_PATH], dest[MAX_PATH];
765 static const WCHAR prefix[] = {'p','f','x',0};
766 DWORD ret;
768 ret = GetTempPathW(MAX_PATH, temp_path);
769 if (ret==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
770 return;
771 ok(ret != 0, "GetTempPathW error %ld\n", GetLastError());
772 ok(ret < MAX_PATH, "temp path should fit into MAX_PATH\n");
774 ret = GetTempFileNameW(temp_path, prefix, 0, source);
775 ok(ret != 0, "GetTempFileNameW error %ld\n", GetLastError());
777 ret = GetTempFileNameW(temp_path, prefix, 0, dest);
778 ok(ret != 0, "GetTempFileNameW error %ld\n", GetLastError());
780 ret = MoveFileW(source, dest);
781 ok(!ret && GetLastError() == ERROR_ALREADY_EXISTS,
782 "CopyFileW: unexpected error %ld\n", GetLastError());
784 ret = DeleteFileW(source);
785 ok(ret, "DeleteFileW: error %ld\n", GetLastError());
786 ret = DeleteFileW(dest);
787 ok(ret, "DeleteFileW: error %ld\n", GetLastError());
790 #define PATTERN_OFFSET 0x10
792 static void test_offset_in_overlapped_structure(void)
794 HANDLE hFile;
795 OVERLAPPED ov;
796 DWORD done;
797 BOOL rc;
798 BYTE buf[256], pattern[] = "TeSt";
799 UINT i;
800 char temp_path[MAX_PATH], temp_fname[MAX_PATH];
802 ok(GetTempPathA(MAX_PATH, temp_path) != 0, "GetTempPathA error %ld\n", GetLastError());
803 ok(GetTempFileNameA(temp_path, "pfx", 0, temp_fname) != 0, "GetTempFileNameA error %ld\n", GetLastError());
805 /*** Write File *****************************************************/
807 hFile = CreateFileA(temp_fname, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
808 ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA error %ld\n", GetLastError());
810 for(i = 0; i < sizeof(buf); i++) buf[i] = i;
811 ok(WriteFile(hFile, buf, sizeof(buf), &done, NULL), "WriteFile error %ld\n", GetLastError());
812 ok(done == sizeof(buf), "expected number of bytes written %lu\n", done);
814 memset(&ov, 0, sizeof(ov));
815 ov.Offset = PATTERN_OFFSET;
816 ov.OffsetHigh = 0;
817 rc=WriteFile(hFile, pattern, sizeof(pattern), &done, &ov);
818 /* Win 9x does not support the overlapped I/O on files */
819 if (rc || GetLastError()!=ERROR_INVALID_PARAMETER) {
820 ok(rc, "WriteFile error %ld\n", GetLastError());
821 ok(done == sizeof(pattern), "expected number of bytes written %lu\n", done);
822 /*trace("Current offset = %04lx\n", SetFilePointer(hFile, 0, NULL, FILE_CURRENT));*/
823 ok(SetFilePointer(hFile, 0, NULL, FILE_CURRENT) == (PATTERN_OFFSET + sizeof(pattern)),
824 "expected file offset %d\n", PATTERN_OFFSET + sizeof(pattern));
826 ov.Offset = sizeof(buf) * 2;
827 ov.OffsetHigh = 0;
828 ok(WriteFile(hFile, pattern, sizeof(pattern), &done, &ov), "WriteFile error %ld\n", GetLastError());
829 ok(done == sizeof(pattern), "expected number of bytes written %lu\n", done);
830 /*trace("Current offset = %04lx\n", SetFilePointer(hFile, 0, NULL, FILE_CURRENT));*/
831 ok(SetFilePointer(hFile, 0, NULL, FILE_CURRENT) == (sizeof(buf) * 2 + sizeof(pattern)),
832 "expected file offset %d\n", sizeof(buf) * 2 + sizeof(pattern));
835 CloseHandle(hFile);
837 /*** Read File *****************************************************/
839 hFile = CreateFileA(temp_fname, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0);
840 ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA error %ld\n", GetLastError());
842 memset(buf, 0, sizeof(buf));
843 memset(&ov, 0, sizeof(ov));
844 ov.Offset = PATTERN_OFFSET;
845 ov.OffsetHigh = 0;
846 rc=ReadFile(hFile, buf, sizeof(pattern), &done, &ov);
847 /* Win 9x does not support the overlapped I/O on files */
848 if (rc || GetLastError()!=ERROR_INVALID_PARAMETER) {
849 ok(rc, "ReadFile error %ld\n", GetLastError());
850 ok(done == sizeof(pattern), "expected number of bytes read %lu\n", done);
851 /*trace("Current offset = %04lx\n", SetFilePointer(hFile, 0, NULL, FILE_CURRENT));*/
852 ok(SetFilePointer(hFile, 0, NULL, FILE_CURRENT) == (PATTERN_OFFSET + sizeof(pattern)),
853 "expected file offset %d\n", PATTERN_OFFSET + sizeof(pattern));
854 ok(!memcmp(buf, pattern, sizeof(pattern)), "pattern match failed\n");
857 CloseHandle(hFile);
859 ok(DeleteFileA(temp_fname), "DeleteFileA error %ld\n", GetLastError());
862 static void test_LockFile(void)
864 HANDLE handle;
865 DWORD written;
866 OVERLAPPED overlapped;
868 handle = CreateFileA( filename, GENERIC_READ | GENERIC_WRITE,
869 FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
870 CREATE_ALWAYS, 0, 0 );
871 if (handle == INVALID_HANDLE_VALUE)
873 ok(0,"couldn't create file \"%s\" (err=%ld)\n",filename,GetLastError());
874 return;
876 ok( WriteFile( handle, sillytext, strlen(sillytext), &written, NULL ), "write failed\n" );
878 ok( LockFile( handle, 0, 0, 0, 0 ), "LockFile failed\n" );
879 ok( UnlockFile( handle, 0, 0, 0, 0 ), "UnlockFile failed\n" );
880 ok( !UnlockFile( handle, 0, 0, 0, 0 ), "UnlockFile succeeded\n" );
882 ok( LockFile( handle, 10, 0, 20, 0 ), "LockFile 10,20 failed\n" );
883 /* overlapping locks must fail */
884 ok( !LockFile( handle, 12, 0, 10, 0 ), "LockFile 12,10 succeeded\n" );
885 ok( !LockFile( handle, 5, 0, 6, 0 ), "LockFile 5,6 succeeded\n" );
886 /* non-overlapping locks must succeed */
887 ok( LockFile( handle, 5, 0, 5, 0 ), "LockFile 5,5 failed\n" );
889 ok( !UnlockFile( handle, 10, 0, 10, 0 ), "UnlockFile 10,10 succeeded\n" );
890 ok( UnlockFile( handle, 10, 0, 20, 0 ), "UnlockFile 10,20 failed\n" );
891 ok( !UnlockFile( handle, 10, 0, 20, 0 ), "UnlockFile 10,20 again succeeded\n" );
892 ok( UnlockFile( handle, 5, 0, 5, 0 ), "UnlockFile 5,5 failed\n" );
894 overlapped.Offset = 100;
895 overlapped.OffsetHigh = 0;
896 overlapped.hEvent = 0;
897 ok( LockFileEx( handle, 0, 0, 100, 0, &overlapped ), "LockFileEx 100,100 failed\n" );
898 /* overlapping shared locks are OK */
899 overlapped.Offset = 150;
900 ok( LockFileEx( handle, 0, 0, 100, 0, &overlapped ), "LockFileEx 150,100 failed\n" );
901 /* but exclusive is not */
902 ok( !LockFileEx( handle, LOCKFILE_EXCLUSIVE_LOCK|LOCKFILE_FAIL_IMMEDIATELY, 0, 50, 0, &overlapped ),
903 "LockFileEx exclusive 150,50 succeeded\n" );
904 ok( UnlockFileEx( handle, 0, 100, 0, &overlapped ), "UnlockFileEx 150,100 failed\n" );
905 ok( !UnlockFileEx( handle, 0, 100, 0, &overlapped ), "UnlockFileEx 150,100 again succeeded\n" );
906 overlapped.Offset = 100;
907 ok( UnlockFileEx( handle, 0, 100, 0, &overlapped ), "UnlockFileEx 100,100 failed\n" );
908 ok( !UnlockFileEx( handle, 0, 100, 0, &overlapped ), "UnlockFileEx 100,100 again succeeded\n" );
910 ok( LockFile( handle, 0, 0x10000000, 0, 0xf0000000 ), "LockFile failed\n" );
911 ok( !LockFile( handle, ~0, ~0, 1, 0 ), "LockFile ~0,1 succeeded\n" );
912 ok( !LockFile( handle, 0, 0x20000000, 20, 0 ), "LockFile 0x20000000,20 succeeded\n" );
913 ok( UnlockFile( handle, 0, 0x10000000, 0, 0xf0000000 ), "UnlockFile failed\n" );
915 /* wrap-around lock should not do anything */
916 /* (but still succeeds on NT4 so we don't check result) */
917 LockFile( handle, 0, 0x10000000, 0, 0xf0000001 );
918 ok( LockFile( handle, ~0, ~0, 1, 0 ), "LockFile ~0,1 failed\n" );
919 ok( UnlockFile( handle, ~0, ~0, 1, 0 ), "Unlockfile ~0,1 failed\n" );
921 /* zero-byte lock */
922 ok( LockFile( handle, 100, 0, 0, 0 ), "LockFile 100,0 failed\n" );
923 ok( !LockFile( handle, 98, 0, 4, 0 ), "LockFile 98,4 succeeded\n" );
924 ok( LockFile( handle, 90, 0, 10, 0 ), "LockFile 90,10 failed\n" );
925 ok( LockFile( handle, 100, 0, 10, 0 ), "LockFile 100,10 failed\n" );
926 ok( UnlockFile( handle, 90, 0, 10, 0 ), "UnlockFile 90,10 failed\n" );
927 ok( UnlockFile( handle, 100, 0, 10, 0 ), "UnlockFile 100,10 failed\n" );
928 ok( UnlockFile( handle, 100, 0, 0, 0 ), "UnlockFile 100,0 failed\n" );
930 CloseHandle( handle );
931 DeleteFileA( filename );
934 static inline int is_sharing_compatible( DWORD access1, DWORD sharing1, DWORD access2, DWORD sharing2 )
936 if (!access1 || !access2) return 1;
937 if ((access1 & GENERIC_READ) && !(sharing2 & FILE_SHARE_READ)) return 0;
938 if ((access1 & GENERIC_WRITE) && !(sharing2 & FILE_SHARE_WRITE)) return 0;
939 if ((access2 & GENERIC_READ) && !(sharing1 & FILE_SHARE_READ)) return 0;
940 if ((access2 & GENERIC_WRITE) && !(sharing1 & FILE_SHARE_WRITE)) return 0;
941 return 1;
944 static void test_file_sharing(void)
946 static const DWORD access_modes[4] = { 0, GENERIC_READ, GENERIC_WRITE, GENERIC_READ|GENERIC_WRITE };
947 static const DWORD sharing_modes[4] = { 0, FILE_SHARE_READ, FILE_SHARE_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE };
948 int a1, s1, a2, s2;
950 /* make sure the file exists */
951 HANDLE h = CreateFileA( filename, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0 );
952 CloseHandle( h );
954 for (a1 = 0; a1 < 4; a1++)
956 for (s1 = 0; s1 < 4; s1++)
958 HANDLE h = CreateFileA( filename, access_modes[a1], sharing_modes[s1],
959 NULL, OPEN_EXISTING, 0, 0 );
960 if (h == INVALID_HANDLE_VALUE)
962 ok(0,"couldn't create file \"%s\" (err=%ld)\n",filename,GetLastError());
963 return;
965 for (a2 = 0; a2 < 4; a2++)
967 for (s2 = 0; s2 < 4; s2++)
969 HANDLE h2 = CreateFileA( filename, access_modes[a2], sharing_modes[s2],
970 NULL, OPEN_EXISTING, 0, 0 );
971 if (is_sharing_compatible( access_modes[a1], sharing_modes[s1],
972 access_modes[a2], sharing_modes[s2] ))
974 ok( h2 != INVALID_HANDLE_VALUE,
975 "open failed for modes %lx/%lx/%lx/%lx err %ld\n",
976 access_modes[a1], sharing_modes[s1],
977 access_modes[a2], sharing_modes[s2], GetLastError() );
979 else
981 ok( h2 == INVALID_HANDLE_VALUE,
982 "open succeeded for modes %lx/%lx/%lx/%lx\n",
983 access_modes[a1], sharing_modes[s1],
984 access_modes[a2], sharing_modes[s2] );
985 if (h2 == INVALID_HANDLE_VALUE)
986 ok( GetLastError() == ERROR_SHARING_VIOLATION,
987 "wrong error code %ld\n", GetLastError() );
989 if (h2 != INVALID_HANDLE_VALUE) CloseHandle( h2 );
992 CloseHandle( h );
995 DeleteFileA( filename );
998 static void test_FindFirstFileA()
1000 HANDLE handle;
1001 WIN32_FIND_DATAA search_results;
1002 int err;
1004 handle = FindFirstFileA("C:\\",&search_results);
1005 err = GetLastError();
1006 ok ( handle == INVALID_HANDLE_VALUE , "FindFirstFile on Root directory should Fail\n");
1007 if (handle == INVALID_HANDLE_VALUE)
1008 ok ( err == ERROR_FILE_NOT_FOUND, "Bad Error number %d\n", err);
1009 handle = FindFirstFileA("C:\\*",&search_results);
1010 ok ( handle != INVALID_HANDLE_VALUE, "FindFirstFile on C:\\* should succeed\n" );
1011 ok ( FindClose(handle) == TRUE, "Failed to close handle\n");
1014 static void test_FindNextFileA()
1016 HANDLE handle;
1017 WIN32_FIND_DATAA search_results;
1018 int err;
1020 handle = FindFirstFileA("C:\\*",&search_results);
1021 ok ( handle != INVALID_HANDLE_VALUE, "FindFirstFile on C:\\* should succeed\n" );
1022 while (FindNextFile(handle, &search_results))
1024 /* get to the end of the files */
1026 ok ( FindClose(handle) == TRUE, "Failed to close handle\n");
1027 err = GetLastError();
1028 ok ( err == ERROR_NO_MORE_FILES, "GetLastError should return ERROR_NO_MORE_FILES\n");
1031 static void test_MapFile()
1033 HANDLE handle, hmap;
1035 /* be sure to remove stale files */
1036 SetFileAttributesA(filename,FILE_ATTRIBUTE_NORMAL);
1037 DeleteFile(filename);
1038 handle = CreateFile( filename, GENERIC_READ|GENERIC_WRITE, 0, 0,
1039 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
1040 ok( handle != INVALID_HANDLE_VALUE, "couldn't create test file\n");
1042 hmap = CreateFileMapping( handle, NULL, PAGE_READWRITE, 0, 0, NULL );
1043 ok( hmap == NULL, "mapped zero size file\n");
1044 ok( GetLastError() == ERROR_FILE_INVALID, "not ERROR_FILE_INVALID\n");
1046 hmap = CreateFileMapping( handle, NULL, PAGE_READWRITE, 0x1000, 0, NULL );
1047 ok( hmap == NULL, "mapping should fail\n");
1048 /* GetLastError() varies between win9x and WinNT */
1050 hmap = CreateFileMapping( handle, NULL, PAGE_READWRITE, 0x1000, 0x10000, NULL );
1051 ok( hmap == NULL, "mapping should fail\n");
1052 /* GetLastError() varies between win9x and WinNT */
1054 hmap = CreateFileMapping( handle, NULL, PAGE_READWRITE, 0, 0x1000, NULL );
1055 ok( hmap != NULL, "mapping should succeed\n");
1057 ok( CloseHandle( hmap ), "can't close mapping handle\n");
1058 ok( CloseHandle( handle ), "can't close file handle\n");
1059 ok( DeleteFileA( filename ), "DeleteFile failed after map\n" );
1062 START_TEST(file)
1064 test__hread( );
1065 test__hwrite( );
1066 test__lclose( );
1067 test__lcreat( );
1068 test__llseek( );
1069 test__llopen( );
1070 test__lread( );
1071 test__lwrite( );
1072 test_GetTempFileNameA();
1073 test_CopyFileA();
1074 test_CopyFileW();
1075 test_CreateFileA();
1076 test_CreateFileW();
1077 test_DeleteFileA();
1078 test_DeleteFileW();
1079 test_MoveFileA();
1080 test_MoveFileW();
1081 test_FindFirstFileA();
1082 test_FindNextFileA();
1083 test_LockFile();
1084 test_file_sharing();
1085 test_offset_in_overlapped_structure();
1086 test_MapFile();