W3Lib local file access problem.
To: "'email@example.com'" <firstname.lastname@example.org>
Subject: W3Lib local file access problem.
From: Teo Kok Hoon <email@example.com>
Date: Mon, 2 Oct 1995 16:34:20 +-800
From firstname.lastname@example.org Mon Oct 2 04: 35:48 1995
I have been working with the library on the Windows platform for a while and would like to point out one problem I faced with local file access.
Looking though the source code (see "HTFile.c", the "HTLoadFile" function), I realise that all local files are opened via a call to
fopen( file->localname,"r" );
My concern is that, for anchors leading to a local file, especially an in-line binary image file, this approach does not correctly complete the fetch of the image data. The reason is simple, a binary file is opened as ASCII.
I have applied the following patch, (not sure if it's the best fix but it works) to resolve the problem through the use of the HTBind series of functions. During the initialisation stage, I bind the image file suffix to "binary" as follows:
HTSecure = YES;
HTBind_setBinding("bmp","image/bmp","binary", NULL, 1.0);
HTBind_setBinding("htm","text/html","8bit", NULL, 1.0);
I've also replaced the earlier code segment in "HTFile.c" with the following.
if (tkh_encoding == WWW_ENC_BINARY)
file->fp = fopen(file->localname,"rb");
file->fp = fopen(file->localname,"r");
Hope this helps people who are facing similar problems =]
Information Technology Institute