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

DirFileNames.h

Go to the documentation of this file.
00001 #ifndef Impala_Util_DirFileNames_h
00002 #define Impala_Util_DirFileNames_h
00003 
00004 #include <string>
00005 #include <vector>
00006 #include "Basis/String.h"
00007 
00008 #ifndef WIN32
00009 #include <dirent.h>
00010 #endif
00011 
00012 namespace Impala
00013 {
00014 namespace Util
00015 {
00016 
00017 #ifdef WIN32
00018 
00019 void
00020 DirFileNames(String dirName, std::vector<String>& fNames)
00021 {
00022     fNames.clear();
00023     dirName += "/*";
00024 
00025     WIN32_FIND_DATAA FindFileData; 
00026     HANDLE hFind = FindFirstFileA(dirName.c_str(), &FindFileData);
00027         if (hFind == INVALID_HANDLE_VALUE)
00028         return;
00029 
00030     do
00031     {
00032         String fileName(FindFileData.cFileName);
00033         fNames.push_back(fileName);
00034         }
00035     while (FindNextFileA(hFind, &FindFileData) != 0);
00036 
00037     FindClose(hFind);
00038 }
00039 
00040 #else
00041 
00042 void
00043 DirFileNames(String dirName, std::vector<String>& fNames)
00044 {
00045     fNames.clear();
00046 
00047     DIR *dp;
00048     if ((dp = opendir(dirName.c_str())) == NULL)
00049         return;
00050 
00051     struct dirent *dirp;
00052     while ((dirp = readdir(dp)) != NULL)
00053     {
00054         String fileName(dirp->d_name);
00055         fNames.push_back(fileName);
00056     }
00057     closedir(dp);
00058     return;
00059 }
00060 
00061 #endif
00062 
00063 } // namespace Util
00064 } // namespace Impala
00065 
00066 #endif

Generated on Fri Mar 19 09:30:39 2010 for ImpalaSrc by  doxygen 1.5.1