Code: Select all
void cDirectoryListing::InternalRetrieve( void )
{
char filePath[512];
#if defined(__unix__)
DIR *dir = opendir(".");
struct dirent *dirp = NULL;
while( ( dirp = readdir( dir ) ) )
{
if( dirp->d_type == DT_DIR && doRecursion )
{
if( strcmp( dirp->d_name, "." ) && strcmp( dirp->d_name, ".." ) )
subdirectories.push_back( cDirectoryListing( currentDir + "/" + dirp->d_name, extension, doRecursion ) );
continue;
}
shortList.push_back( dirp->d_name );
sprintf( filePath, "%s/%s", currentDir.c_str(), dirp->d_name );
filenameList.push_back( filePath );
}
Ok since the latest thing is to try to get it working in linux, I said i'll try my hand with it on Solaris. It mostly compiles except for a few problems. The main one I found was this piece of code.
The d_type member in struct dirent isn't POSIX compliant. If you define __USE_BSD it will work on Linux because it supports this but looking at "man standards" I found out that solaris doesn't support this standard. I think one can rewrite this using stat() if someone feels up to it and make it Unix compilable too
Just messing with it and thought I'd post it here for reference if anyone ever needs to get it compiled on Solaris, they'll know what to do