To identify executable and other files in QT Application
Hi,
I am using file dialog to open a particular folder or disk and see files in it which is of QT executable , text, image format files.
How do i identify whether the opened file is executable or text or image file. As all you know , No file extension for linux files.
( My idea is if file opened is executable i will use Qprocess to execute it otherwise if it is text file i will use Qtextstream to read it .)
I
Re: To identify executable and other files in QT Application
You mention Linux. Do you know the file command? It will tell you a file type. Take a look here to see how it works
http://linux.about.com/library/cmd/blcmdl1_file.htm
Note, that this will identify links as links. On Windows, I believe that file extension is used.
Re: To identify executable and other files in QT Application
Linux uses mime types instead of extensions, so you would get the mime type for your file and if it says "executable", then you would use QProcess to execute it/etc.
If you are unsure of the mime type used for a particular file, you can use the 'mimetype' command to figure it out. It's like 'file' but uses mime types instead of descriptions.
Re: To identify executable and other files in QT Application
I use fedora, and it supports the file command, but not mimetype. I do have a high level of curiosity, however, so I poked around a bit.
I am stating what I believe to be true with hopes that you will correct me if I am incorrect.
- Gnome uses mime types to associate applications with files.
- Gnome mime types use magic numbers to recognize the mime type.
- There may be multiple associations for a specific type; for example, an OOo document may associate to an OOo document type and also to a ZIP file. This is, of course, as it should be.
I looked at the gnome mime-type stuff in the file /etc/gnome-vfs-mime-magic
Very interesting...