summaryrefslogtreecommitdiff
path: root/apps/plugins/random_folder_advance_config.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/random_folder_advance_config.c')
-rw-r--r--apps/plugins/random_folder_advance_config.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/apps/plugins/random_folder_advance_config.c b/apps/plugins/random_folder_advance_config.c
index ca0d5f397d..2c9fb411ac 100644
--- a/apps/plugins/random_folder_advance_config.c
+++ b/apps/plugins/random_folder_advance_config.c
@@ -211,7 +211,7 @@ static bool custom_dir(void)
211 rb->close(fd2); 211 rb->close(fd2);
212 if(errors) 212 if(errors)
213 /* Press button to continue */ 213 /* Press button to continue */
214 rb->get_action(CONTEXT_STD, TIMEOUT_BLOCK); 214 rb->get_action(CONTEXT_STD, TIMEOUT_BLOCK);
215 } 215 }
216 else 216 else
217 return false; 217 return false;
@@ -259,11 +259,11 @@ static int load_list(void)
259 { 259 {
260 return -2; 260 return -2;
261 } 261 }
262 262
263 rb->read(myfd,buffer,buffer_size); 263 rb->read(myfd,buffer,buffer_size);
264 rb->close(myfd); 264 rb->close(myfd);
265 list = (struct file_format *)buffer; 265 list = (struct file_format *)buffer;
266 266
267 return 0; 267 return 0;
268} 268}
269 269
@@ -288,7 +288,7 @@ static int save_list(void)
288 rb->lseek(myfd,0,SEEK_SET); 288 rb->lseek(myfd,0,SEEK_SET);
289 rb->write(myfd,&dirs_count,sizeof(int)); 289 rb->write(myfd,&dirs_count,sizeof(int));
290 rb->close(myfd); 290 rb->close(myfd);
291 291
292 return 1; 292 return 1;
293} 293}
294 294
@@ -298,22 +298,22 @@ static int edit_list(void)
298 bool exit = false; 298 bool exit = false;
299 int button,i; 299 int button,i;
300 int selection, ret = 0; 300 int selection, ret = 0;
301 301
302 /* load the dat file if not already done */ 302 /* load the dat file if not already done */
303 if ((list == NULL || list->count == 0) && (i = load_list()) != 0) 303 if ((list == NULL || list->count == 0) && (i = load_list()) != 0)
304 { 304 {
305 rb->splashf(HZ*2, "Could not load %s, rv = %d", RFA_FILE, i); 305 rb->splashf(HZ*2, "Could not load %s, rv = %d", RFA_FILE, i);
306 return -1; 306 return -1;
307 } 307 }
308 308
309 dirs_count = list->count; 309 dirs_count = list->count;
310 310
311 rb->gui_synclist_init(&lists,list_get_name_cb,0, false, 1, NULL); 311 rb->gui_synclist_init(&lists,list_get_name_cb,0, false, 1, NULL);
312 rb->gui_synclist_set_icon_callback(&lists,NULL); 312 rb->gui_synclist_set_icon_callback(&lists,NULL);
313 rb->gui_synclist_set_nb_items(&lists,list->count); 313 rb->gui_synclist_set_nb_items(&lists,list->count);
314 rb->gui_synclist_limit_scroll(&lists,true); 314 rb->gui_synclist_limit_scroll(&lists,true);
315 rb->gui_synclist_select_item(&lists, 0); 315 rb->gui_synclist_select_item(&lists, 0);
316 316
317 while (!exit) 317 while (!exit)
318 { 318 {
319 rb->gui_synclist_draw(&lists); 319 rb->gui_synclist_draw(&lists);
@@ -387,22 +387,22 @@ static int export_list_to_file_text(void)
387 rb->splashf(HZ*2, "Could not load %s, rv = %d", RFA_FILE, i); 387 rb->splashf(HZ*2, "Could not load %s, rv = %d", RFA_FILE, i);
388 return 0; 388 return 0;
389 } 389 }
390 390
391 if (list->count <= 0) 391 if (list->count <= 0)
392 { 392 {
393 rb->splashf(HZ*2, "no dirs in list file: %s", RFA_FILE); 393 rb->splashf(HZ*2, "no dirs in list file: %s", RFA_FILE);
394 return 0; 394 return 0;
395 } 395 }
396 396
397 /* create and open the file */ 397 /* create and open the file */
398 int myfd = rb->creat(RFA_FILE_TEXT, 0666); 398 int myfd = rb->creat(RFA_FILE_TEXT, 0666);
399 if (myfd < 0) 399 if (myfd < 0)
400 { 400 {
401 rb->splashf(HZ*4, "failed to open: fd = %d, file = %s", 401 rb->splashf(HZ*4, "failed to open: fd = %d, file = %s",
402 myfd, RFA_FILE_TEXT); 402 myfd, RFA_FILE_TEXT);
403 return -1; 403 return -1;
404 } 404 }
405 405
406 /* write each directory to file */ 406 /* write each directory to file */
407 for (i = 0; i < list->count; i++) 407 for (i = 0; i < list->count; i++)
408 { 408 {
@@ -411,7 +411,7 @@ static int export_list_to_file_text(void)
411 rb->fdprintf(myfd, "%s\n", list->folder[i]); 411 rb->fdprintf(myfd, "%s\n", list->folder[i]);
412 } 412 }
413 } 413 }
414 414
415 rb->close(myfd); 415 rb->close(myfd);
416 rb->splash(HZ, "Done"); 416 rb->splash(HZ, "Done");
417 return 1; 417 return 1;
@@ -420,7 +420,7 @@ static int export_list_to_file_text(void)
420static int import_list_from_file_text(void) 420static int import_list_from_file_text(void)
421{ 421{
422 char line[MAX_PATH]; 422 char line[MAX_PATH];
423 423
424 buffer = rb->plugin_get_audio_buffer(&buffer_size); 424 buffer = rb->plugin_get_audio_buffer(&buffer_size);
425 if (buffer == NULL) 425 if (buffer == NULL)
426 { 426 {
@@ -434,11 +434,11 @@ static int import_list_from_file_text(void)
434 rb->splashf(HZ*2, "failed to open: %s", RFA_FILE_TEXT); 434 rb->splashf(HZ*2, "failed to open: %s", RFA_FILE_TEXT);
435 return -1; 435 return -1;
436 } 436 }
437 437
438 /* set the list structure, and initialize count */ 438 /* set the list structure, and initialize count */
439 list = (struct file_format *)buffer; 439 list = (struct file_format *)buffer;
440 list->count = 0; 440 list->count = 0;
441 441
442 while ((rb->read_line(myfd, line, MAX_PATH - 1)) > 0) 442 while ((rb->read_line(myfd, line, MAX_PATH - 1)) > 0)
443 { 443 {
444 /* copy the dir name, and skip the newline */ 444 /* copy the dir name, and skip the newline */
@@ -448,16 +448,16 @@ static int import_list_from_file_text(void)
448 { 448 {
449 if (line[len-1] == 0x0A || line[len-1] == 0x0D) 449 if (line[len-1] == 0x0A || line[len-1] == 0x0D)
450 line[len-1] = 0x00; 450 line[len-1] = 0x00;
451 if (len > 1 && 451 if (len > 1 &&
452 (line[len-2] == 0x0A || line[len-2] == 0x0D)) 452 (line[len-2] == 0x0A || line[len-2] == 0x0D))
453 line[len-2] = 0x00; 453 line[len-2] = 0x00;
454 } 454 }
455 455
456 rb->strcpy(list->folder[list->count++], line); 456 rb->strcpy(list->folder[list->count++], line);
457 } 457 }
458 458
459 rb->close(myfd); 459 rb->close(myfd);
460 460
461 if (list->count == 0) 461 if (list->count == 0)
462 { 462 {
463 load_list(); 463 load_list();
@@ -484,14 +484,14 @@ static int start_shuffled_play(void)
484 rb->splashf(HZ*2, "Not enough memory for shuffling"); 484 rb->splashf(HZ*2, "Not enough memory for shuffling");
485 return 0; 485 return 0;
486 } 486 }
487 487
488 /* load the dat file if not already done */ 488 /* load the dat file if not already done */
489 if ((list == NULL || list->count == 0) && (i = load_list()) != 0) 489 if ((list == NULL || list->count == 0) && (i = load_list()) != 0)
490 { 490 {
491 rb->splashf(HZ*2, "Could not load %s, rv = %d", RFA_FILE, i); 491 rb->splashf(HZ*2, "Could not load %s, rv = %d", RFA_FILE, i);
492 return 0; 492 return 0;
493 } 493 }
494 494
495 if (list->count <= 0) 495 if (list->count <= 0)
496 { 496 {
497 rb->splashf(HZ*2, "no dirs in list file: %s", RFA_FILE); 497 rb->splashf(HZ*2, "no dirs in list file: %s", RFA_FILE);
@@ -507,7 +507,7 @@ static int start_shuffled_play(void)
507 } 507 }
508 for(i=0;i<list->count;i++) 508 for(i=0;i<list->count;i++)
509 order[i]=i; 509 order[i]=i;
510 510
511 for(i = list->count - 1; i >= 0; i--) 511 for(i = list->count - 1; i >= 0; i--)
512 { 512 {
513 /* the rand is from 0 to RAND_MAX, so adjust to our value range */ 513 /* the rand is from 0 to RAND_MAX, so adjust to our value range */
@@ -518,7 +518,7 @@ static int start_shuffled_play(void)
518 order[candidate] = order[i]; 518 order[candidate] = order[i];
519 order[i] = store; 519 order[i] = store;
520 } 520 }
521 521
522 /* We don't want whatever is playing */ 522 /* We don't want whatever is playing */
523 if (!(rb->playlist_remove_all_tracks(NULL) == 0 523 if (!(rb->playlist_remove_all_tracks(NULL) == 0
524 && rb->playlist_create(NULL, NULL) == 0)) 524 && rb->playlist_create(NULL, NULL) == 0))
@@ -643,6 +643,6 @@ enum plugin_status plugin_start(const void* parameter)
643#endif 643#endif
644 644
645 cancel = false; 645 cancel = false;
646 646
647 return main_menu(); 647 return main_menu();
648} 648}