/*
//----------------------------------------------------------------------------
// Getting list of all files for given directory
// Arguments
// pszDirectoryPath : Directory path
// pszFiles : Fill up file names in it
// Return int : No of files found in given directory
//----------------------------------------------------------------------------*/
int GetFilesNames(const char *pszDirectoryPath, char **pszFiles)
{
WIN32_FIND_DATA findFileData;
HANDLE hFind = INVALID_HANDLE_VALUE;
int nIndex = 0;
hFind = FindFirstFile(pszDirectoryPath, &findFileData);
if (hFind == INVALID_HANDLE_VALUE)
{
return 0;
}
do
{
if(!(findFileData.dwFileAttributes &FILE_ATTRIBUTE_DIRECTORY))
{
pszFiles[nIndex] = (char *) calloc(BUFFER_SIZE, sizeof(char));
strcpy(pszFiles[nIndex], findFileData.cFileName);
//printf("\n===> %s", pszFiles[nIndex]);
nIndex++;
}
} while(FindNextFile(hFind, &findFileData));
FindClose(hFind);
return nIndex;
}
Wednesday, 21 May 2014
C / C++ : Getting list of all files for given directory
Labels:
C & C++,
Programming
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment