Forgot to seek before trying to read back data, and added a check for the data integrity

svn path=/trunk/; revision=1193
This commit is contained in:
Phillip Susi 2000-06-17 22:04:49 +00:00
parent 4e91635e4a
commit e6bcb9741d

View file

@ -21,33 +21,34 @@ int main( void )
0,
0);
if (file == INVALID_HANDLE_VALUE)
{
printf("Error opening file (Status %x)\n", GetLastError());
return 1;
}
if (file == INVALID_HANDLE_VALUE)
{
printf("Error opening file (Status %x)\n", GetLastError());
return 1;
}
for( c = 0; c < sizeof( buffer ); c++ )
buffer[c] = (char)c;
printf("Writing file\n");
for (c = 0; c < 1024; c++)
if (WriteFile( file, buffer, 4096, &wrote, NULL) == FALSE)
{
if (WriteFile( file, buffer, 4096, &wrote, NULL) == FALSE)
{
printf("Error writing file (Status %x)\n", GetLastError());
exit(2);
}
}
printf("Error writing file (Status %x)\n", GetLastError());
exit(2);
}
printf("Reading file\n");
for (c = 0; c < 1024; c++)
SetFilePointer( file, 0, 0, FILE_BEGIN );
if (ReadFile( file, buffer, 4096, &wrote, NULL) == FALSE)
{
if (ReadFile( file, buffer, 4096, &wrote, NULL) == FALSE)
{
printf("Error reading file (Status %x)\n", GetLastError());
exit(3);
}
printf("Error reading file (Status %x)\n", GetLastError());
exit(3);
}
printf("Finished\n");
for( c = 0; c < sizeof( buffer ); c++ )
if( buffer[c] != (char)c )
{
printf( "Error: data read back is not what was written\n" );
CloseHandle( file );
return 0;
}
printf("Finished, works fine\n");
CloseHandle( file );
return 0;
}