Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

FileInfo.h

Go to the documentation of this file.
00001 #ifndef Impala_Util_FileInfo_h
00002 #define Impala_Util_FileInfo_h
00003 
00004 #include "Persistency/Types.h"
00005 
00006 
00007 namespace Impala
00008 {
00009 namespace Util
00010 {
00011 
00012 
00013 class DirectoryInfo;
00014 
00015 class FileInfo
00016 {
00017 public:
00018     FileInfo(const std::string& name, DirectoryInfo* directory)
00019         : mName(name)
00020     {
00021         mDirectory=directory;
00022     }
00023 
00024     std::string
00025     GetName()
00026     {
00027         return mName;
00028     }
00029 
00030     std::string mName;
00031     DirectoryInfo* mDirectory;
00032 };
00033 
00034 inline Persistency::CollectableType
00035 File2Type(const FileInfo* file)
00036 {
00037     std::string::size_type pos = file->mName.rfind('.');
00038     if (pos == std::string::npos)
00039         return Persistency::TypeUnknown;
00040 
00041     std::string ext = file->mName.substr(pos);
00042     if (ext == ".png" || ext == ".jpg" || ext == ".gif" || ext == ".bmp")
00043         return Persistency::TypeImage;
00044     if (ext == ".mpg" || ext == ".avi" || ext == ".mp2" || ext == ".wmv")
00045         return Persistency::TypeVideo;
00046     if (ext == ".mp3" || ext == ".wav" || ext == ".au")
00047         return Persistency::TypeAudio;
00048     if (ext == ".txt" || ext == ".text" || ext == ".h" || ext == ".c" || ext == ".cpp")
00049         return Persistency::TypeText;
00050     return Persistency::TypeUnknown;
00051 }
00052 
00053 inline std::string
00054 File2TypeName(const FileInfo* file)
00055 {
00056     return Persistency::CollectableType2String(File2Type(file));
00057 }
00058 
00059 } // namespace Util
00060 } // namespace Impala
00061 
00062 #endif Impala_Util_FileInfo_h

Generated on Fri Mar 19 09:31:46 2010 for ImpalaSrc by  doxygen 1.5.1