?
@Noctis: hm, nachdem das ganze nach windows user riecht...
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <direct.h>
#include <windows.h>
inline bool getCwd( char **ppcDest );
bool runThrough( char *pcDir );
int main( int argc, char *argv[] )
{
char *cwd = NULL;
if( !getCwd( &cwd ) ) {
cprintf( "Couldn't determine current working directory!\r\n" );
getch();
return -1;
}
cprintf( "%s\r\n", cwd );
// begin our cracy run ;)
runThrough( cwd );
free( cwd );
return 0;
}
inline bool getCwd( char **ppcDest )
{
return ( *ppcDest = _getdcwd( _getdrive(), NULL, 0 ) ) != NULL;
}
bool runThrough( char *pcDir )
{
char *pcFindPattern = (char*) malloc( strlen(pcDir) + 3 );
if( !pcFindPattern )
return false;
sprintf( pcFindPattern, "%s\\*", pcDir );
WIN32_FIND_DATA findData;
HANDLE hFind = FindFirstFile( pcFindPattern, &findData );
free( pcFindPattern );
if( hFind == INVALID_HANDLE_VALUE )
return false;
do {
cprintf( "%s\r\n", findData.cFileName );
if( findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) {
if( strncmp( findData.cFileName, ".", strlen(findData.cFileName) ) != 0 &&
strncmp( findData.cFileName, "..", strlen(findData.cFileName) ) ) {
char *pcSubDir = (char*) malloc( strlen(pcDir) + strlen(findData.cFileName) + 2 );
if( !pcSubDir ) {
FindClose( hFind );
return false;
}
sprintf( pcSubDir, "%s\\%s", pcDir, findData.cFileName );
runThrough( pcSubDir );
free( pcSubDir );
}
}
} while( FindNextFile( hFind, &findData ) );
FindClose( hFind );
}
aber bitte, um himmelswillen, google mal nach rekursion
@ others: Könnt' das mal einer lesen, der Ahnung hat? Hab' schon ziemlich lange nix mehr proggt -> gebt euren Senf dazu
greetz, neox86