Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Removed file that shouldn't be there.
[xestiaab/.git] / source / common / mime.cpp
1 #include <wx/wx.h>
3 wxString GetMIME(wxString FilenameInc){
4     
5     wxString MIMEResult;
6     
7     // Check if file exists first before doing anything with it.
8     
9     if (!wxFileExists(FilenameInc)){
10         
11         // File doesn't exist so return.
12         
13         wxMessageBox(_("The file with the filename given doesn't exist."), _("Error opening picture/audio file"), wxICON_ERROR);
14         return wxEmptyString;
15         
16     }
17     
18 #if defined(__WIN32__)
19     
20     // TODO: Sort out Win32.
21     
22 #else
23     
24 #include <stdio.h>
25     
26     FILE *MIMEIn;
27     
28     char MIMEData[512];
29     
30     // Build Command Line.
31     
32     wxString FilenameIncEscaped = FilenameInc;
33     FilenameIncEscaped.Replace(wxT(" "), wxT("\\ "));
34     wxString FileCommandLine;
35     
36     FileCommandLine.Append("file -b --mime-type ");
37     FileCommandLine.Append(FilenameIncEscaped);
38     
39     if (!(MIMEIn = popen(FileCommandLine.mb_str(), "r"))){
40         
41         wxMessageBox(_("The file with the filename given doesn't exist."), _("Error opening picture/audio file"), wxICON_ERROR);
42         return wxEmptyString;
43         
44     }
45     
46     while(fgets(MIMEData, sizeof(MIMEData), MIMEIn) != NULL){
47         MIMEResult.Append(wxString::FromUTF8(MIMEData));
48     }
49     pclose(MIMEIn);
50     
51     MIMEResult.Trim();
52     
53 #endif
54     
55 /*#else
56     
57 #include <magic.h>
58     
59     const char *MIMEType;
60     magic_t MagicCookie = magic_open(MAGIC_MIME);
61     magic_setflags(MagicCookie, MAGIC_MIME_TYPE);
62     
63     if (!MagicCookie){
64         
65         wxMessageBox(_("An error occured with the support library for getting the picture/audio type."), _("Error opening picture/audio file"), wxICON_ERROR);
66         return wxEmptyString;
67         
68     }
69     
70     if (magic_load(MagicCookie, NULL) != 0) {
71         
72         wxMessageBox(_("An error occured whilst determining the picture/audio type."), _("Error opening picture/audio file"), wxICON_ERROR);
73         return wxEmptyString;
74         
75     }
76     
77     MIMEType = magic_file(MagicCookie, FilenameInc.mb_str());
78     MIMEResult = wxString::FromUTF8(MIMEType);
79     magic_close(MagicCookie);
80     
81 #endif*/
82     
83     return MIMEResult;
84     
85 }
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy