Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

filetype.cpp

Go to the documentation of this file.
00001 // filetype.cpp
00002 //
00003 // Copyright (C) 2001, Chris Laurel <claurel@shatters.net>
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 
00010 #include <cctype>
00011 #include <cstdlib>
00012 #include "util.h"
00013 #include "filetype.h"
00014 
00015 using namespace std;
00016 
00017 
00018 static const string JPEGExt(".jpeg");
00019 static const string JPGExt(".jpg");
00020 static const string JFIFExt(".jif");
00021 static const string BMPExt(".bmp");
00022 static const string TargaExt(".tga");
00023 static const string PNGExt(".png");
00024 static const string ThreeDSExt(".3ds");
00025 static const string CelestiaTextureExt(".ctx");
00026 static const string CelestiaMeshExt(".cms");
00027 static const string CelestiaCatalogExt(".ssc");
00028 static const string CelestiaStarCatalogExt(".stc");
00029 static const string CelestiaDeepSkyCatalogExt(".dsc");
00030 static const string AVIExt(".avi");
00031 static const string DDSExt(".dds");
00032 static const string CelestiaLegacyScriptExt(".cel");
00033 static const string CelestiaScriptExt(".clx");
00034 static const string CelestiaScriptExt2(".celx");
00035 static const string CelestiaModelExt(".cmod");
00036 
00037 
00038 ContentType DetermineFileType(const string& filename)
00039 {
00040     int extPos = filename.rfind('.');
00041     if (extPos == (int)string::npos)
00042         return Content_Unknown;
00043     string ext = string(filename, extPos, filename.length() - extPos + 1);
00044 
00045     if (compareIgnoringCase(JPEGExt, ext) == 0 ||
00046         compareIgnoringCase(JPGExt, ext) == 0 ||
00047         compareIgnoringCase(JFIFExt, ext) == 0)
00048         return Content_JPEG;
00049     else if (compareIgnoringCase(BMPExt, ext) == 0)
00050         return Content_BMP;
00051     else if (compareIgnoringCase(TargaExt, ext) == 0)
00052         return Content_Targa;
00053     else if (compareIgnoringCase(PNGExt, ext) == 0)
00054         return Content_PNG;
00055     else if (compareIgnoringCase(ThreeDSExt, ext) == 0)
00056         return Content_3DStudio;
00057     else if (compareIgnoringCase(CelestiaTextureExt, ext) == 0)
00058         return Content_CelestiaTexture;
00059     else if (compareIgnoringCase(CelestiaMeshExt, ext) == 0)
00060         return Content_CelestiaMesh;
00061     else if (compareIgnoringCase(CelestiaCatalogExt, ext) == 0)
00062         return Content_CelestiaCatalog;
00063     else if (compareIgnoringCase(CelestiaStarCatalogExt, ext) == 0)
00064         return Content_CelestiaStarCatalog;
00065     else if (compareIgnoringCase(CelestiaDeepSkyCatalogExt, ext) == 0)
00066         return Content_CelestiaDeepSkyCatalog;
00067     else if (compareIgnoringCase(AVIExt, ext) == 0)
00068         return Content_AVI;
00069     else if (compareIgnoringCase(DDSExt, ext) == 0)
00070         return Content_DDS;
00071     else if (compareIgnoringCase(CelestiaLegacyScriptExt, ext) == 0)
00072         return Content_CelestiaLegacyScript;
00073     else if (compareIgnoringCase(CelestiaScriptExt, ext) == 0 ||
00074              compareIgnoringCase(CelestiaScriptExt2, ext) == 0)
00075         return Content_CelestiaScript;
00076     else if (compareIgnoringCase(CelestiaModelExt, ext) == 0)
00077         return Content_CelestiaModel;
00078     else
00079         return Content_Unknown;
00080 }

Generated on Sat Jan 14 22:30:32 2006 for Celestia by  doxygen 1.4.1