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

DirFileNames.h

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

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