maintenance.c
/* compare a list of table entries e to a list of file names d and 
act appropriately at each comparison. Almost
exactly the merge routine of merge sort */
compare a list of table entries e to a list of file names d and
act appropriately at each comparison. Almost
exactly the merge routine of merge sort
compare a list of table entries e to a list of file names d and act appropriately at each comparison . Almost exactly the merge routine of merge sort
int compare(char d_names[][MAX_CHARS], int d_size,
            char e_names[][MAX_CHARS], int e_size)
{
    int d_idx = 0, e_idx = 0;
    while (d_idx < d_size && e_idx < e_size)
    {
        int comparison = strcmp(d_names[d_idx], e_names[e_idx]);
        if (comparison == 0)
        {
            d_idx++;
            e_idx++;
        }
        else if (comparison < 0)
        {
            if (insert_to_database(d_names[d_idx]))
            {
                return 1;
            }
            d_idx++;
        }
        else
        {
            if (remove_from_database(e_names[e_idx]))
            {
                return 1;
            }
            e_idx++;
        }
    }
    while (d_idx < d_size)
    {
        insert_to_database(d_names[d_idx]);
        d_idx++;
    }
    while (e_idx < e_size)
    {
        remove_from_database(e_names[e_idx]);
        e_idx++;
    }
    return 0;
}
int compare ( char d_names [ ] [ MAX_CHARS ] , int d_size , char e_names [ ] [ MAX_CHARS ] , int e_size ) { int d_idx = 0 , e_idx = 0 ; while ( d_idx < d_size && e_idx < e_size ) { int comparison = strcmp ( d_names [ d_idx ] , e_names [ e_idx ] ) ; if ( comparison == 0 ) { d_idx ++ ; e_idx ++ ; } else if ( comparison < 0 ) { if ( insert_to_database ( d_names [ d_idx ] ) ) { return 1 ; } d_idx ++ ; } else { if ( remove_from_database ( e_names [ e_idx ] ) ) { return 1 ; } e_idx ++ ; } } while ( d_idx < d_size ) { insert_to_database ( d_names [ d_idx ] ) ; d_idx ++ ; } while ( e_idx < e_size ) { remove_from_database ( e_names [ e_idx ] ) ; e_idx ++ ; } return 0 ; }
compare a list of table entries e to a list of file names d and
act appropriately at each comparison.
compare a list of table entries e to a list of file names d and act appropriately at each comparison .
// the directory has a name the database does not // add it and its associated data to the database // the database has a name the directory does not // remove it from the database // there are still files in the directory not // in the database // add them all // there are still files left to be removed // remove each