config/make.tmpl(%build_module): Support use of _rel libs in uselibs=
[AROS.git] / test / fileseek.c
blob3c389a50458bf67d335ea950b1276763133f5776
1 #include <stdio.h>
2 #include <proto/dos.h>
3 #include <dos/dos.h>
4 #include <stdlib.h>
6 int main()
8 FILE *fd;
9 char buffer[32];
10 int i;
11 BPTR file;
13 fd = fopen( "seek.txt", "wb" );
14 if ( !fd )
16 fprintf( stderr, "Could not write test file seek.txt\n" );
17 exit(-1);
19 fprintf( fd, "() does not work!\n" );
20 fclose(fd);
22 /* fseek() */
23 fd = fopen( "seek.txt", "rb" );
24 if ( !fd )
26 fprintf( stderr, "Could not open test file seek.txt\n" );
27 exit(-1);
29 i = fread( buffer, 1, 1, fd );
30 //printf("pos=%ld\n",ftell(fd));
31 i += fread( &buffer[1], 1, 6, fd );
32 if( i != 7 )
34 fprintf( stderr, "Wanted to fread() %d chars, but could only get %d!\n", 6, i-1 );
35 exit(-1);
37 fseek( fd, 4, SEEK_CUR );
38 i = fread( &buffer[7], 1, 11, fd );
39 buffer[7+i]=0;
40 printf( "fseek%s", buffer );
41 fclose(fd);
43 /* Seek() */
44 file = Open( "seek.txt", MODE_OLDFILE );
45 i = Read( file, buffer, 7 );
46 Seek( file, 4, OFFSET_CURRENT );
47 i += Read( file, &buffer[7], 11 );
48 buffer[i] = 0;
49 printf( "\nSeek%s", buffer );
51 return 0;