grub2: bring back build of aros-side grub2 tools
[AROS.git] / test / misc / fileseek.c
blob6215c55a59ca1e45b9fae00b3243bc39ee6d9aff
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <stdio.h>
7 #include <proto/dos.h>
8 #include <dos/dos.h>
9 #include <stdlib.h>
11 int main()
13 FILE *fd;
14 char buffer[32];
15 int i;
16 BPTR file;
18 fd = fopen( "seek.txt", "wb" );
19 if ( !fd )
21 fprintf( stderr, "Could not write test file seek.txt\n" );
22 exit(RETURN_ERROR);
24 fprintf( fd, "() does not work!\n" );
25 fclose(fd);
27 /* fseek() */
28 fd = fopen( "seek.txt", "rb" );
29 if ( !fd )
31 fprintf( stderr, "Could not open test file seek.txt\n" );
32 exit(RETURN_ERROR);
34 i = fread( buffer, 1, 1, fd );
35 //printf("pos=%ld\n",ftell(fd));
36 i += fread( &buffer[1], 1, 6, fd );
37 if( i != 7 )
39 fprintf( stderr, "Wanted to fread() %d chars, but could only get %d!\n", 6, i-1 );
40 exit(RETURN_ERROR);
42 fseek( fd, 4, SEEK_CUR );
43 i = fread( &buffer[7], 1, 11, fd );
44 buffer[7+i]=0;
45 printf( "fseek%s", buffer );
46 fclose(fd);
48 /* Seek() */
49 file = Open( "seek.txt", MODE_OLDFILE );
50 i = Read( file, buffer, 7 );
51 Seek( file, 4, OFFSET_CURRENT );
52 i += Read( file, &buffer[7], 11 );
53 buffer[i] = 0;
54 printf( "\nSeek%s", buffer );
56 return RETURN_OK;