[Qt-interest] How to check between "Text" and "Non-Text"

Jeroen De Wachter jeroen.dewachter at barco.com
Tue Apr 20 11:37:35 CEST 2010


I really don't know if file reads the entire file, I haven't looked at 
the code...
It seems the file command is actually using libmagic to check for file 
types, so you may be able to simply use libmagic (and avoid copying 
loads of code from the file program)

You can find the sources here (each version contains both libmagic and 
file):

ftp://ftp.astron.com/pub/file/

You might be better off just getting the sources for your Linux 
distribution though (if you're using one).
With apt-based distributions, you can get the source by calling

apt-get source *packagename*

On my ubuntu machine the packages are called libmagic-dev (development 
headers for libmagic), libmagic1 (actual library) and file (for the file 
command using libmagic).
I just apt-got the libmagic1 sources and got the sources for all of it.

Kind regards,

Jeroen

yogesh upreti wrote:
> Hallo All,
> Thanks a lot for all the replys.
>  
> @Frederic:
> I am using right now readline method to read the file, and it's not 
> working very nicely for binary data (probably it is looking for LF or CR)
> which method should I use for reading file which will give me no 
> difference between normal and binary file? Also I don't wanna scan the 
> whole file through, How much data should I read to find a good 
> comparision for ?
>  
> @Wachter:
> Where can I find source for "file" command may be reading only header 
> could be sufficient for me. I was looking something like this because 
> with this I don't have to read the whole file through, because some 
> binary files are huge (2-3 GB).
>  
> Does anyone knows what logic programmes like Notepad/WordPad use to 
> find out if it is a Text or Non-Text file?
>  
> Thanks a lot
> Yogesh Upreti
> ------------------------------------------------------------------------
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>   



DISCLAIMER:
Unless indicated otherwise, the information contained in this message is privileged and confidential, and is intended only for the use of the addressee(s) named above and others who have been specifically authorized to receive it. If you are not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this message and/or attachments is strictly prohibited. The company accepts no liability for any damage caused by any virus transmitted by this email. Furthermore, the company does not warrant a proper and complete transmission of this information, nor does it accept liability for any delays. If you have received this message in error, please contact the sender and delete the message. Thank you.




More information about the Qt-interest-old mailing list