0

hello guys!I would like to give a little help for a problem which stops me from my project.

take a look plz...<br>

void traverseDir( string dirname ){
    string   str;
    DIR *pDIR;
    struct dirent *entry;
    pDIR=opendir(dirname.c_str());
while((entry = readdir(pDIR)) != NULL ){
      if( isDir( dirname.c_str() ) ) {
	if( strcmp(entry->d_name, ".") != 0 
                        && strcmp(entry->d_name, "..") != 0 ){
            	        cout << entry->d_name <<endl;
                        string pathDir = dirname + "/" + ( entry->d_name );
                         traverseDir( pathDir );
                        cout <<"verify: " << dirname <<endl;
                         chdir( dirname.c_str() );
	}
      }
       else {
         	cout << "This is file: " << entry->d_name <<endl;
      }
		
} //while
      closedir(pDIR);
}

compiler borland C++ 5.02.
Fault:Access Violation at 0x406be3:
read of address 0x8.
I'would be really appreciate if you could give me a hand.Thanks for the moment...

1
Contributor
1
Reply
2
Views
8 Years
Discussion Span
Last Post by sirus23
0

hello guys!I would like to put some notes as for the function isDir.

bool isDir(const char* _dir)
{
	bool bResult = true;

	if ( strlen(_dir) > 0)
	{
		if(GetFileAttributes(_dir) != FILE_ATTRIBUTE_DIRECTORY)
			bResult= false;
	}

	return bResult;
}

Thanks a lot...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.