ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> activetcl
activetcl
Re: [Activetcl] Strange Problem with ::fileutil::fileType
by Andreas Kupries other posts by this author
May 13 2008 9:09AM messages near this date
view in the new Beta List Site
[Activetcl] Strange Problem with ::fileutil::fileType | [Activetcl] teacup bug affecting update-self not fixable by update-self or get
>  I have a strange problem using ::fileutil::fileType.  I have a file
>  exported from the Windows registry section [HKEY_LOCAL_MACHINE] and it
>  is about 121MB in size.  When I run the ::fileutil::fileType on this
>  file it returns "binary audio mpeg".  This is odd because this file is
>  plain text.  However poking around the ::fileutil::fileType source code
>  I can **find** the characters that would trigger the file to be a binary
>  audio file.  These characters are located deep within the exported file.
>  So I shortened the file to 121 KB (starting from the bottom-the top part
>  remained the same) and now ::fileutil::fileType returns "text".

>  Further poking into ::fileutil::fileType reveals that it defines a
>  buffer size of 1024 and then reads 1024 bytes into the buffer and
>  immediately closes the file.  So I assume that it reads the first 1024
>  bytes to determine the file type.

Yes.

>  Why is it behaving this way?

I am guessing that the code assumes that the magic markers which determine
the type of a file are found within the first KB of a file. Beyond that you
would have to ask the author of this procedure (Phil Ehrens, noted at the
top of the file. I have no idea if the email is still valid).

While I have extended this command in the past the basic design was done at
the time and the decisions regarding it _not_ recorded anywhere as far as I
know.

The 'These characters are located deep within the exported file.' however
seem to indicate that the code is reading not the first KB, but deeper in
the file ?

--
	Andreas Kupries <andreask@[...].com> 
	Developer @ http://www.ActiveState.com
	Tel: +1 778-786-1122


_______________________________________________
ActiveTcl mailing list
ActiveTcl@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Michael Bahr
Andreas Kupries

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved