CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2003
    Location
    Saxony&Bavaria/Germany
    Posts
    28

    what is wrong with the recursion

    //search all subdirectories (recursion)
    void SearchAllDir(char *argv1, char *argv2)
    {

    struct find_t sdir; //file attribute in a struct
    char buffer[500]; //buffer of path (drive and directory)
    char buffer2[500]; //buffer of path (drive and directory)
    int result; //result of subdirectories

    //arrays to NULL
    *buffer = NULL;
    *buffer2 = NULL;

    //drive letter to buffer
    strcpy(buffer,argv1);
    //add ':\'
    strcat(buffer,":\\");
    //add path of directories
    strcat(buffer,argv2);

    // printf("%s\n",&buffer);
    // printf("%s\n",&buffer2);

    //buffer to buffer2 for dates
    strcpy(buffer2, buffer);

    //next level of subdirectories
    strcat(buffer,"\\*.*");

    //search first subdirectory in the next level
    result = _dos_findfirst( buffer, _A_SUBDIR, &sdir);

    //_dos_finfirst return '0' if true
    while(result == 0)
    {
    //is there any subdirectory
    if( sdir.attrib & _A_SUBDIR )
    {
    //no subdirectories which begins with '.' like '.' and '..'
    if(sdir.name[0] != '.')
    {
    *buffer = NULL; //empty buffer
    strcpy(buffer,argv2); //add complete path to buffer
    strcat(buffer,"\\"); //add '\'
    strcat(buffer,sdir.name); //add name of subdirectory

    // printf("%s\n",&buffer);

    //recursion (with new path)
    SearchAllDir(argv1, buffer);

    //read actual date und creation dates of subdirectories
    if(SearchDates(argv1,buffer) == 1)
    {
    Wait();

    //delete files in directory
    DelFiles(argv1, buffer);

    //delete directories
    DelDir(argv1,buffer);

    }

    }

    }

    //if there is no lower level go to next directory
    result = _dos_findnext(&sdir);
    }

    }
    life is a game...

  2. #2
    Join Date
    Aug 2002
    Location
    Hamburg / Germany
    Posts
    280
    Hi,
    ok this might be the ONLY posting you receive on this, and I think you should know why:

    Do you think we have lot's of spare-time to figure out what your code does and what it doesn't. Ok your code looks not unfamilliar to me, but I DON'T WANT to dig through this.. sorry.

    So please: In minimal tell us what your problem with this code is. It is not very kind to just throw a bunch of code to the crowd at codeguru and ask to find the problem.

    we are not employed by you, and for that reason something like "thanks in advance" or "thanks for helping" might have been a good idea.

    greetings

    Juergen

  3. #3
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652
    Well...I do not know exactly what the purpose of the function is, however, as a reference you might take a look at this FAQ which I assume basically does what you want...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured