simulator_modules/memory.c
/** memory directory count file
 * This function expects a list of size the amount of files in the directory and fills that list
 * with the absolute file paths of the files in that directory
 * @param directory_path the path of the directory
 * @param list the list in which the file paths should be saved
 * @param list_element_max_size the size of the elements in the list
 * @return 1 if everything is fine, -1 if the directory could not be opened, -2 if a file path was longer than element max size
 */
memory directory count file
This function expects a list of size the amount of files in the directory and fills that list
with the absolute file paths of the files in that directory
@param directory_path the path of the directory
@param list the list in which the file paths should be saved
@param list_element_max_size the size of the elements in the list
@return 1 if everything is fine, -1 if the directory could not be opened, -2 if a file path was longer than element max size
memory directory count file This function expects a list of size the amount of files in the directory and fills that list with the absolute file paths of the files in that directory @param directory_path the path of the directory @param list the list in which the file paths should be saved @param list_element_max_size the size of the elements in the list @return 1 if everything is fine - 1 if the directory could not be opened - 2 if a file path was longer than element max size
int32_t memory_directory_get_filenames(char *directory_path, char **list,
                                       int32_t list_element_max_size)
{
	struct dirent *pDirent;
	DIR *pDir;
	int32_t file_counter = 0;
	int32_t ret = 1;
    char abs_directory_path[256];
	snprintf(abs_directory_path, 256, "%s/%s", path_in_windows, directory_path);
	pDir = opendir(abs_directory_path);
    if (pDir != NULL)
	{
		while ((pDirent = readdir(pDir)) != NULL)
		{
			printf("[%s]\n", pDirent->d_name);
			if (pDirent->d_name[0] == '.')
			{
			}
			else
			{
				int32_t path_size =
				    snprintf(list[file_counter++], list_element_max_size,
				             "%s/%s", directory_path, pDirent->d_name);
				if (path_size > list_element_max_size)
				{
					ret = -2;
				}
			}
		}
	}
	else
	{
		printf("Cannot open directory '%s'\n", directory_path);
	}
	closedir(pDir);
	return ret;
}
int32_t memory_directory_get_filenames ( char * directory_path , char * * list , int32_t list_element_max_size ) { struct dirent * pDirent ; DIR * pDir ; int32_t file_counter = 0 ; int32_t ret = 1 ; char abs_directory_path [ 256 ] ; snprintf ( abs_directory_path , 256 , " " , path_in_windows , directory_path ) ; pDir = opendir ( abs_directory_path ) ; if ( pDir != NULL ) { while ( ( pDirent = readdir ( pDir ) ) != NULL ) { printf ( " \n " , pDirent -> d_name ) ; if ( pDirent -> d_name [ 0 ] == ' ' ) { } else { int32_t path_size = snprintf ( list [ file_counter ++ ] , list_element_max_size , " " , directory_path , pDirent -> d_name ) ; if ( path_size > list_element_max_size ) { ret = -2 ; } } } } else { printf ( " \n " , directory_path ) ; } closedir ( pDir ) ; return ret ; }
memory directory count file
 This function expects a list of size the amount of files in the directory and fills that list
 with the absolute file paths of the files in that directory
 @param directory_path the path of the directory
 @param list the list in which the file paths should be saved
 @param list_element_max_size the size of the elements in the list
 @return 1 if everything is fine, -1 if the directory could not be opened, -2 if a file path was longer than element max size
memory directory count file This function expects a list of size the amount of files in the directory and fills that list with the absolute file paths of the files in that directory @param directory_path the path of the directory @param list the list in which the file paths should be saved @param list_element_max_size the size of the elements in the list @return 1 if everything is fine - 1 if the directory could not be opened - 2 if a file path was longer than element max size
// Ensure we can open directory. // Ensure we can open directory. // ignore dot entries // Close directory and exit.