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

DirImageFileNames.h

Go to the documentation of this file.
00001 //345678901234567890123456789012345678901234567890123456789012345678901234567890
00002 // Obtain image filenames in given directory
00003 //
00004 // Author: Richard van Balen
00005 
00006 #ifndef Impala_Util_DirImageFileNames_h
00007 #define Impala_Util_DirImageFileNames_h
00008 
00009 #include <string>
00010 #include <vector>
00011 #include "Basis/FileName.h"
00012 
00013 #ifndef WIN32
00014 #include <dirent.h>
00015 #endif
00016 
00017 namespace Impala {
00018 namespace Util {
00019 
00020 /*
00021 std::string DirFindRaw(std::string dirName)
00022 {
00023     WIN32_FIND_DATA FindFileData; 
00024     HANDLE          hFind = INVALID_HANDLE_VALUE; 
00025 
00026     dirName += "/*raw";
00027 
00028     hFind = FindFirstFile(dirName.c_str(), &FindFileData);
00029         if(hFind == INVALID_HANDLE_VALUE)
00030         return "";
00031     return FindFileData.cFileName;
00032 }
00033 */
00034 
00035 #ifdef WIN32
00036 
00037 void DirImageFileNames(std::string dirName, std::vector<std::string*>& fNames)
00038 {
00039     WIN32_FIND_DATA FindFileData; 
00040     HANDLE          hFind = INVALID_HANDLE_VALUE; 
00041     std::string*    fileName;
00042 
00043     fNames.clear();
00044     dirName += "/*";
00045 
00046     hFind = FindFirstFile(dirName.c_str(), &FindFileData);
00047         if(hFind == INVALID_HANDLE_VALUE)
00048         return;
00049 
00050     do {
00051         std::string ext = FileNameExt(FindFileData.cFileName,true);
00052         if (ext == "jpg" || ext == "jpeg" || ext == "png" || ext == "raw")
00053         {
00054             fileName = new std::string(FindFileData.cFileName);
00055             fNames.push_back(fileName);
00056         }
00057         } while(FindNextFile(hFind, &FindFileData) != 0);
00058 
00059     FindClose(hFind);
00060 }
00061 
00062 #else
00063 
00064 void DirImageFileNames(std::string dirName, std::vector<std::string*>& fNames)
00065 {
00066     DIR *dp;
00067     struct dirent *dirp;
00068     std::string* fileNameP;
00069 
00070     fNames.clear();
00071 
00072     if((dp  = opendir(dirName.c_str())) == NULL) {
00073         return;
00074     }
00075 
00076 
00077     while ((dirp = readdir(dp)) != NULL) {
00078         std::string fileName = std::string(dirp->d_name);
00079         std::string ext = FileNameExt(fileName,true);
00080         if (ext == "jpg" || ext == "jpeg" || ext == "png" || ext == "raw")
00081         {
00082             fileNameP = new std::string(fileName);
00083             fNames.push_back(fileNameP);
00084         }
00085     }
00086     closedir(dp);
00087     return;
00088 }
00089 
00090 #endif
00091 
00092 } // namespace Util
00093 } // namespace Impala
00094 #endif

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