Hi.
I'm quit new in this and i'm wondering how can be the easyest way to see it some file is texture or not.
I have read man file and man magic but i realy can not understand how to use.
So i hope that someone can help me.
Tnx
Hi.
I'm quit new in this and i'm wondering how can be the easyest way to see it some file is texture or not.
I have read man file and man magic but i realy can not understand how to use.
So i hope that someone can help me.
Tnx
Do you mean texture as in if its an image file or? Then you would need to read up on the different file-formats you want to be able to recognize and see what they contain as marker for that specific kind of filetype. For instance a BMP file will have 2 bytes at the very start filled with BM to make you recognize it as a BMP file.
Well if you are just trying to pick out image files, file will do what you need:
Code:jeff@jeff-gate:~$ file ./iltb.jpg ./iltb.jpg: JPEG image data, JFIF standard 1.01, comment: "Created with GIMP\377" jeff@jeff-gate:~$
Hi.
I mean, that i whant to check all kinda files and use proper one, texture type.
I try something very similar that jeffcob write.
In shell i use:
file -i something
something: application/x-executable; charset=binary
or
file -i Unsaved.txt
Unsaved.txt: text/plain; charset=us-ascii
So i want this kinda command for shell use in my C application.
So i did with example:
system("file -i Unsaved.txt") or system("file -i something") and return me result.
So i got another problem, And i'm having a new question.
If is possible when i use in my C application system("file -i Unsaved.txt"); and when return me some result i want use in my if statement only the files which are texture type like in my example for Unsaved. So if return me that is text kinda file i want this texture file rename.
But still, how can i retreave and use it in my if statement.
Otherwise i read somewhere that maybe i can do semeting with glib mime.
I hope that u understand what i write.
Tnx for help.
Not sure I am following your problem correctly so if this is wrong I am sorry but I would look into the popen command described here: popen
I use this for called command line apps and getting the results to use in an application. Still not sure what you meant by texture though -- example?