What’s a cross-platform way for getting a user-friendly description of a file?
Examples:
- foo.pdf -> “Portable Document Format (PDF)
- bar.doc -> “Microsoft Word Document”
Pointers to libraries or appropriate system APIs would be highly appreciated.
A Qt/C++ solution is preferred but anything is fine.
Target platforms are Windows and Mac OS X. I’d prefer the descriptions to match what would be found in Explorer or Finder if possible (rather than maintaining a map of extensions -> descriptions myself).
The GNU File command is builtin for Linux and OSX, and there is a version available for Windows (http://gnuwin32.sourceforge.net/packages/file.htm).
You could invoke the file command using QProcess and display the returned info.
Output looks like :