1 --- src/base/ftsystem.c.origf Mon Dec 29 05:45:54 2003
2 +++ src/base/ftsystem.c Mon Dec 29 05:46:08 2003
15 /* We use the macro STREAM_FILE for convenience to extract the */
16 /* system-specific stream handle from a given FreeType stream object */
17 -#define STREAM_FILE( stream ) ( (FILE*)stream->descriptor.pointer )
18 +#define STREAM_FD( stream ) ( (int)stream->descriptor.value )
21 /*************************************************************************/
23 FT_CALLBACK_DEF( void )
24 ft_ansi_stream_close( FT_Stream stream )
26 - fclose( STREAM_FILE( stream ) );
27 + close(STREAM_FD(stream));
29 stream->descriptor.pointer = NULL;
32 unsigned char* buffer,
39 - file = STREAM_FILE( stream );
40 + fd = STREAM_FD( stream );
42 - fseek( file, offset, SEEK_SET );
43 + if(lseek( fd, offset, SEEK_SET ) < 0) return 0;
45 - return (unsigned long)fread( buffer, 1, count, file );
46 + return (unsigned long) read(fd,buffer,count);
51 FT_Stream_Open( FT_Stream stream,
52 const char* filepathname )
59 return FT_Err_Invalid_Stream_Handle;
61 - file = fopen( filepathname, "rb" );
63 + fd = open( filepathname, O_RDONLY);
66 FT_ERROR(( "FT_Stream_Open:" ));
67 FT_ERROR(( " could not open `%s'\n", filepathname ));
69 return FT_Err_Cannot_Open_Resource;
72 - fseek( file, 0, SEEK_END );
73 - stream->size = ftell( file );
74 - fseek( file, 0, SEEK_SET );
75 + n = lseek( fd, 0, SEEK_END );
76 + stream-> size = n < 0 ? 0 : n;
77 + lseek( fd, 0, SEEK_SET );
79 - stream->descriptor.pointer = file;
80 + stream->descriptor.value = fd;
81 stream->pathname.pointer = (char*)filepathname;