Tcl Library Source Code

View Ticket
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Ticket UUID: 1329207
Title: mimetype, filetype result empty for text files
Type: Bug Version: None
Submitter: kot Created on: 2005-10-18 05:48:58
Subsystem: fileutil :: magic Assigned To: andreas_kupries
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2018-08-28 17:44:58
Resolution: Fixed Closed By:
    Closed on:
Description:
modules/fumagic/filetypes.test
- tcltest 2.2.8
- fileutil::magic::filetype 1.0
  - fileutil::magic::rt     1.0

==== fumagic.filetype-1.2 test file directory FAILED
==== Contents of test case:

    set f [file join $dir fileTypeTest]
    set res [catch {fileutil::magic::filetype $f} msg]
    regsub {file[0-9]+} $msg {fileXXX} msg
    list $res $msg

---- Result was:
0 {}
---- Result should have been (exact matching):
1 {error reading "fileXXX": illegal operation on a
directory}
==== fumagic.filetype-1.2 FAILED

modules/fumagic/mimetypes.test
- tcltest 2.2.8
- fileutil::magic::mimetype 1.0
  - fileutil::magic::rt     1.0

==== fumagic.mimetype-1.2 test file directory FAILED
==== Contents of test case:

    set f [file join $dir fileTypeTest]
    set res [catch {fileutil::magic::mimetype $f} msg]
    regsub {file[0-9]+} $msg {fileXXX} msg
    list $res $msg

---- Result was:
0 {}
---- Result should have been (exact matching):
1 {error reading "fileXXX": illegal operation on a
directory}



In fact, trying to apply to a text file, such as
/var/log/messages or /COPYRIGHT returns nothing --
[rt::resultv] seems to be an empty list.

Using the procedure on some other things -- like
picture files -- seems to work, however.
User Comments: pooryorick added on 2018-08-28 17:44:58:

Some of these issues were previously fixed, and issues that apply to the current implementation are fixed in [62cc52d167857f94]. A welcome additional feature would be recognition of character sets and encodings.


andreas_kupries added on 2006-09-28 04:20:45:
Logged In: YES 
user_id=75003

Fixed the test failures. Committed to head.
Nothing done yet regarding /var/log/messages, copyright, etc.

dgp added on 2006-09-27 22:43:49:
Logged In: YES 
user_id=80530


still fail in 
- tcllib::testutils 1.1
- fileutil::magic::rt 1.0
* fileutil::magic::filetype 1.0.1
(tcllib-1.9-rc1)

on Solaris 9

kot added on 2005-10-19 00:07:00:
Logged In: YES 
user_id=173641

file(1), when applied to a directory responds with 
"directory" -- try `file /' on any system. 
 
/var/log/message is readable to all on my system and 
yes, I did try other text file (/COPYRIGHT, for example). 
 
file(1) works properly: 
 
% file /COPYRIGHT  
/COPYRIGHT: ASCII English text

andreas_kupries added on 2005-10-18 23:49:24:
Logged In: YES 
user_id=75003

The directory failures seem to be BSD specific. Solaris
could have them too, as that allows to read a directory is
if it were a file.

Regarding /var/log/messages, what user were you ? IIRC this
file is usually read-only root, i.e. unaccessible to anybody
else. Right now I have now idea how fumagic will react if it
doesn't have the permissions to read a file. You could try
to make readable copies of messages and COPYRIGHT and try to
get results for that.

Have you also tried it on other text files, not only pictures ?