~ubuntu-branches/ubuntu/precise/primrose/precise

« back to all changes in this revision

Viewing changes to minorGems/network/web/MimeTyper.h

  • Committer: Bazaar Package Importer
  • Author(s): Paul Wise
  • Date: 2009-04-06 19:26:56 UTC
  • Revision ID: james.westby@ubuntu.com-20090406192656-cri7503gebyvfl8t
Tags: upstream-5+dfsg1
ImportĀ upstreamĀ versionĀ 5+dfsg1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Modification History
 
3
 *
 
4
 * 2002-April-20    Jason Rohrer
 
5
 * Created.
 
6
 *
 
7
 * 2002-September-17    Jason Rohrer
 
8
 * Moved mime.ini into settings directory.
 
9
 *
 
10
 * 2002-October-7    Jason Rohrer
 
11
 * Added a function for getting mime types from file names.
 
12
 *
 
13
 * 2003-September-1   Jason Rohrer
 
14
 * Copied into minorGems from the konspire2b project.
 
15
 */
 
16
 
 
17
 
 
18
 
 
19
#ifndef MIME_TYPER_INCLUDED
 
20
#define MIME_TYPER_INCLUDED
 
21
 
 
22
 
 
23
 
 
24
#include <stdio.h>
 
25
 
 
26
 
 
27
 
 
28
/**
 
29
 * A class that can resolve file extensions to mime types.
 
30
 *
 
31
 * @author Jason Rohrer
 
32
 */
 
33
class MimeTyper {
 
34
 
 
35
 
 
36
        
 
37
    public:
 
38
 
 
39
 
 
40
 
 
41
        /**
 
42
         * Constructs a mime typer.
 
43
         *
 
44
         * @param inFileName the configuration file from, or
 
45
         *   NULL to specify the default file name, "mime.ini".
 
46
         *   File name is relative to the settings directory.
 
47
         *   Defaults to NULL.
 
48
         *   Must be destroyed by caller if non-NULL and non-const.
 
49
         */
 
50
        MimeTyper( char *inConfigFileName = NULL );
 
51
 
 
52
        ~MimeTyper();
 
53
        
 
54
 
 
55
        
 
56
        /**
 
57
         * Gets a mime type string from a file extension string.
 
58
         *
 
59
         * @param inFileExtension a \0-terminated string containing
 
60
         *   a file extension, including the '.'
 
61
         *   Must be destroyed by caller if non-const.
 
62
         *
 
63
         * @return the mime type as a \0-terminated string,
 
64
         *   or NULL if there is no match.
 
65
         *   Must be destroyed by caller if non-NULL.
 
66
         */
 
67
        char *getMimeType( char *inFileExtension );
 
68
 
 
69
 
 
70
 
 
71
        /**
 
72
         * Gets a mime type string from a file name.
 
73
         *
 
74
         * @param inFileName a \0-terminated string containing
 
75
         *   a file name with extension.
 
76
         *   Must be destroyed by caller if non-const.
 
77
         *
 
78
         * @return the mime type as a \0-terminated string,
 
79
         *   or NULL if there is no match.
 
80
         *   Must be destroyed by caller if non-NULL.
 
81
         */
 
82
        char *getFileNameMimeType( char *inFileName );
 
83
 
 
84
        
 
85
 
 
86
    protected:
 
87
 
 
88
 
 
89
        
 
90
        // a string containing all types read from the configuration file
 
91
        char *mMimeTypesString;
 
92
 
 
93
        
 
94
        
 
95
    };
 
96
 
 
97
 
 
98
 
 
99
#endif
 
100