Thank You for your continued support and contributions!
char oldfilename[13] = "filename.bmp";char newfilename[13];char *pointer;pointer = strrchr(oldfilename,'.');*pointer = '\0';strcpy(newfilename,oldfilename);
#include "plugin.h"PLUGIN_HEADERstatic struct plugin_api* rb;enum plugin_status plugin_start(struct plugin_api* api, void* parameter){ (void)parameter; DIR* dir; struct dirent *entry; char files[60][60], folders[6][36]; //first is number of elements, second is length char display_path[MAX_PATH]; char *pointer; int fileCount, folderCount, randNum; rb = api; fileCount = 0; folderCount = 0; randNum = 0; rb->strcpy(folders[0],THEME_DIR); do { if(randNum > 0){ rb->strcat(folders[0],folders[randNum]); } dir = rb->opendir(folders[0]); rb->strcpy(folders[0],THEME_DIR); entry = rb->readdir(dir); entry = rb->readdir(dir); while(0 != (entry = rb->readdir(dir))) { if(entry->attribute & ATTR_DIRECTORY) { folderCount++; rb->strcpy(folders[folderCount],"/"); rb->strcat(folders[folderCount],entry->d_name); } else if( !rb->strcasecmp(rb->strrchr(entry->d_name,'.'),".cfg") && rb->strcmp(entry->d_name,"rockbox_default.cfg") ) { if(randNum > 0){ rb->strcpy(files[fileCount],folders[randNum]); rb->strcat(files[fileCount],"/"); } else{ rb->strcpy(files[fileCount],"/"); } rb->strcat(files[fileCount],entry->d_name); fileCount++; } } rb->closedir(dir); randNum++; }while(randNum <= folderCount);/******************************************************************//* Gets random number and reduces it to within range of fileCount */ rb->srand(*rb->current_tick); randNum = rb->rand(); while(randNum > 10000){ randNum = randNum / fileCount; } while(randNum >= fileCount){ randNum = randNum - fileCount; }/************************************************//* strips ".cfg" from end and "/" from begining *//* filename to display */rb->strcpy(display_path,files[randNum]);pointer = rb->strrchr(display_path,'.');*pointer = '\0';pointer = rb->strrchr(display_path,'/')+1; rb->splash(50,pointer); rb->lcd_update();/******************************************//* Compiles entire path of selected theme */ rb->strcpy(display_path,folders[0]); rb->strcat(display_path,files[randNum]); rb->settings_load_config(display_path,true);//rb->button_get(true); return PLUGIN_OK;}
Page created in 0.07 seconds with 22 queries.