mirror of
https://github.com/reactos/reactos.git
synced 2024-09-11 05:12:43 +00:00
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:
parent
4e91635e4a
commit
e6bcb9741d
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue