4u2change/msdb.c
uint16_t msdb_communityCount() 
{
    DIR                 *dir_p           = NULL;
    struct  dirent      *dirEntry_p      = NULL;
    char    tmpPath[ES_MAX_DIR_FILE_NAME_LEN];
    struct stat file_info;
    uint8_t              count           = 0;

    /* Initialise storage structure. */
    memset(tmpPath,  0, sizeof(tmpPath));

    snprintf(tmpPath, sizeof(tmpPath), STORAGE_COMMUNITIES_DIRECTORY);
    dir_p = opendir(tmpPath);
    if (NULL != dir_p) {

        while (NULL != (dirEntry_p = readdir(dir_p))) {
            if ((strcmp(dirEntry_p->d_name,  ".") != 0) &&
                (strcmp(dirEntry_p->d_name, "..") != 0)) {
                memset(tmpPath,  0, sizeof(tmpPath));
                snprintf(tmpPath, sizeof(tmpPath), "%s/%s", 
                         STORAGE_COMMUNITIES_DIRECTORY, dirEntry_p->d_name);

                if ((!stat(tmpPath, &file_info)) && 
                    (S_ISREG(file_info.st_mode))) {
                    count++;
                }
            }
        }
        closedir(dir_p);
    }

    return count;
}
/***************************************************************************/
/**
 * The number of stored communities.
 *
 * @return A count indicating the number of stored communities.
 ******************************************************************************/
The number of stored communities.
@return A count indicating the number of stored communities.
The number of stored communities . @return A count indicating the number of stored communities .
uint16_t msdb_communityCount() 
{
    DIR                 *dir_p           = NULL;
    struct  dirent      *dirEntry_p      = NULL;
    char    tmpPath[ES_MAX_DIR_FILE_NAME_LEN];
    struct stat file_info;
    uint8_t              count           = 0;
    memset(tmpPath,  0, sizeof(tmpPath));
    snprintf(tmpPath, sizeof(tmpPath), STORAGE_COMMUNITIES_DIRECTORY);
    dir_p = opendir(tmpPath);
    if (NULL != dir_p) {
        while (NULL != (dirEntry_p = readdir(dir_p))) {
            if ((strcmp(dirEntry_p->d_name,  ".") != 0) &&
                (strcmp(dirEntry_p->d_name, "..") != 0)) {
                memset(tmpPath,  0, sizeof(tmpPath));
                snprintf(tmpPath, sizeof(tmpPath), "%s/%s", 
                         STORAGE_COMMUNITIES_DIRECTORY, dirEntry_p->d_name);
                if ((!stat(tmpPath, &file_info)) && 
                    (S_ISREG(file_info.st_mode))) {
                    count++;
                }
            }
        }
        closedir(dir_p);
    }
    return count;
}
uint16_t msdb_communityCount ( ) { DIR * dir_p = NULL ; struct dirent * dirEntry_p = NULL ; char tmpPath [ ES_MAX_DIR_FILE_NAME_LEN ] ; struct stat file_info ; uint8_t count = 0 ; memset ( tmpPath , 0 , sizeof ( tmpPath ) ) ; snprintf ( tmpPath , sizeof ( tmpPath ) , STORAGE_COMMUNITIES_DIRECTORY ) ; dir_p = opendir ( tmpPath ) ; if ( NULL != dir_p ) { while ( NULL != ( dirEntry_p = readdir ( dir_p ) ) ) { if ( ( strcmp ( dirEntry_p -> d_name , " " ) != 0 ) && ( strcmp ( dirEntry_p -> d_name , " " ) != 0 ) ) { memset ( tmpPath , 0 , sizeof ( tmpPath ) ) ; snprintf ( tmpPath , sizeof ( tmpPath ) , " " , STORAGE_COMMUNITIES_DIRECTORY , dirEntry_p -> d_name ) ; if ( ( ! stat ( tmpPath , & file_info ) ) && ( S_ISREG ( file_info . st_mode ) ) ) { count ++ ; } } } closedir ( dir_p ) ; } return count ; }
The number of stored communities.
The number of stored communities .
/* Initialise storage structure. */