3 wxString GetMIME(wxString FilenameInc){
7 // Check if file exists first before doing anything with it.
9 if (!wxFileExists(FilenameInc)){
11 // File doesn't exist so return.
13 wxMessageBox(_("The file with the filename given doesn't exist."), _("Error opening picture/audio file"), wxICON_ERROR);
18 #if defined(__WIN32__)
20 // TODO: Sort out Win32.
30 // Build Command Line.
32 wxString FilenameIncEscaped = FilenameInc;
33 FilenameIncEscaped.Replace(wxT(" "), wxT("\\ "));
34 wxString FileCommandLine;
36 FileCommandLine.Append("file -b --mime-type ");
37 FileCommandLine.Append(FilenameIncEscaped);
39 if (!(MIMEIn = popen(FileCommandLine.mb_str(), "r"))){
41 wxMessageBox(_("The file with the filename given doesn't exist."), _("Error opening picture/audio file"), wxICON_ERROR);
46 while(fgets(MIMEData, sizeof(MIMEData), MIMEIn) != NULL){
47 MIMEResult.Append(wxString::FromUTF8(MIMEData));
60 magic_t MagicCookie = magic_open(MAGIC_MIME);
61 magic_setflags(MagicCookie, MAGIC_MIME_TYPE);
65 wxMessageBox(_("An error occured with the support library for getting the picture/audio type."), _("Error opening picture/audio file"), wxICON_ERROR);
70 if (magic_load(MagicCookie, NULL) != 0) {
72 wxMessageBox(_("An error occured whilst determining the picture/audio type."), _("Error opening picture/audio file"), wxICON_ERROR);
77 MIMEType = magic_file(MagicCookie, FilenameInc.mb_str());
78 MIMEResult = wxString::FromUTF8(MIMEType);
79 magic_close(MagicCookie);