LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   file types (https://www.linuxquestions.org/questions/programming-9/file-types-501599/)

vijraj 11-14-2006 04:21 PM

file types
 
Hi Everyone!

I am working on a c program which displays all the directories and files under each directory.
I want to know what kind of file each is. Like, is the file an ascii text file or english text or a c file.
if it is an executable, is it an binary file or a shell script.
I was told to look inside the file to achieve this.How should I do this.Man pages are difficult to understand and quite confusing.Any help is appreciated.
Thanks in advance.

acid_kewpie 11-14-2006 04:34 PM

check out the functionality from the standard libmagic http://www.die.net/doc/linux/man/man3/libmagic.3.html

vijraj 11-14-2006 07:25 PM

Thankyou,acid_kewpie!

vijraj 11-14-2006 08:07 PM

Hi acid_kewpie!

Can u give me an example of how to read a file for bytes and then decide what it is.I am all confused.
Like, stat returned and says it is a regular file is a regular file.
So from now what should I do?
Thanks for ur help.

acid_kewpie 11-15-2006 02:37 AM

i've not used libmagic to be honest, it's just the c / c++ bindings to the same backend that the "file" program uses.


All times are GMT -5. The time now is 07:31 AM.