Design Introduction “Air” Styles Mobile Design Principles Styles UX Overview Design Patterns UI Components for Tizen App Design 2.3 TV Design Principles Styles UX Overview Patterns UI Components Wearable Development Tizen Studio Overview Download Tizen Studio Deprecation Notice Tizen Extensions for Visual Studio Family IoT extension SDK Docs Blog Blog Announcing the Tizen Studio 3.7 Release Announcing the Tizen Studio 3.1 Release Community Forums General Support Tizen .NET Web Application Development Native Application Development SDK & IDE Design Introduction “Air” Styles Mobile Design Principles Styles UX Overview Design Patterns UI Components for Tizen App Design 2.3 TV Design Principles Styles UX Overview Patterns UI Components Wearable Development Tizen Studio Overview Download Tizen Studio Deprecation Notice Tizen Extensions for Visual Studio Family IoT extension SDK Docs Blog Blog Announcing the Tizen Studio 3.7 Release Announcing the Tizen Studio 3.1 Release Community Forums General Support Tizen .NET Web Application Development Native Application Development SDK & IDE
List files in a directory using readdir of dirent.h
Hello to all,
I have a problem, well read list of files in a directory is not the proble, I have this code and works properly:
char buff[1024]; ad->label = elm_label_add(ad->conform); sprintf(buff,"Hello "); struct dirent* dent; struct stat st; //if(( stat(DIR_MAIN, &st) != -1 ) && ( stat(DIR_TRK, &st) != -1 )){ sprintf(buff,"%s 1", buff); DIR* srcdir = opendir(DIR_TRK); if (srcdir != NULL){ sprintf(buff,"%s 2", buff); while((dent = readdir(srcdir)) != NULL){ //if(strcmp(dent->d_name, ".") == 0 || strcmp(dent->d_name, "..") == 0) // continue; //if (fstatat(dirfd(srcdir), dent->d_name, &st, 0) < 0){ if(stat(dent->d_name, &st)) sprintf(buff,"%s, %s", buff,dent->d_name); } closedir(srcdir); } /*else perror ("Couldn't open the directory");*/ //} elm_object_text_set(ad->label, buff); evas_object_size_hint_weight_set(ad->label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); elm_object_content_set(ad->conform, ad->label); /* Show window after base gui is set up */ evas_object_show(ad->win);But, this is only a test, the real target is put the file names in a Genlist, and I did this code:
static char *_item_label_get(void *data, Evas_Object *obj, const char *part) { char *i = (char *) data; //char *buf=calloc(255, sizeof(char)); if (!strcmp(part, "elm.text")) { //strncpy(buf, i, 254); //return buf; return strdup(i); } else return NULL; } char buff[255]; sprintf(buff,"Hello "); struct dirent* dent; struct stat st; //if(( stat(DIR_MAIN, &st) != -1 ) && ( stat(DIR_TRK, &st) != -1 )){ DIR* srcdir = opendir(DIR_TRK); if (srcdir != NULL){ while((dent = readdir(srcdir)) != NULL){ //if(strcmp(dent->d_name, ".") == 0 || strcmp(dent->d_name, "..") == 0) // continue; //if (fstatat(dirfd(srcdir), dent->d_name, &st, 0) < 0){ if(stat(dent->d_name, &st)){ //strncpy(buff,dent->d_name, 254); //buff[254] = '\0'; elm_genlist_item_append(genlist, itc, (void *)dent->d_name, //(void *)buff, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); } } closedir(srcdir); } /*else perror ("Couldn't open the directory");*/ //} elm_genlist_item_class_free(itc); }And is generated a list with number of elements of files in the directory, but no names! Any suggestion please!
Thanks to all!
BY
16 Apr 2025
Tizen Studio
BY
04 Nov 2024
Tizen Studio
BY
02 Apr 2024
Tizen Studio