is there any "good" way to distinguish between movie file and image file? I would like to know what exactly my "std::wstring filePath" is - a movie, or an image. Therefore, I could go further with strong assurance I am working with known file type.
In other words, I have two classes MyImage and MyMovie both need path to file in their constructors. I would like to verify path to file somehow before creating one of those classes.
bool isMovie(const std::wstring & filePath);
bool isImage(const std::wstring & filePath);
Of course I thought about file extensions, but I'm not sure that it is good and not prone to errors solution. So is it good to use file extension or any other feasible solution is possible.?
Thanks in advance
You can use libmagic to detect what kind of file it is. You pass the file path in and it'll give you a textual description or MIME type for the file.