W3C home > Mailing lists > Public > www-lib@w3.org > October to December 1995

W3Lib local file access problem.

From: Teo Kok Hoon <kokhoon@iti.gov.sg>
Date: Mon, 2 Oct 1995 16:34:20 +-800
Message-Id: <01BA90E4.F0C697C0@p-chuncheng.iti.gov.sg>
To: "'www-lib@w3.org'" <www-lib@w3.org>

    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:

	if (HTLibInit())
		if (HTClientHost)
			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 =]

Kok Hoon,
Information Technology Institute
Received on Monday, 2 October 1995 04:35:48 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:33:46 UTC