diff options
Diffstat (limited to 'apps/onplay.c')
-rw-r--r-- | apps/onplay.c | 83 |
1 files changed, 59 insertions, 24 deletions
diff --git a/apps/onplay.c b/apps/onplay.c index 2f0ee3b861..52d5d20c6e 100644 --- a/apps/onplay.c +++ b/apps/onplay.c | |||
@@ -507,6 +507,34 @@ static bool vbr_fix(void) | |||
507 | return false; | 507 | return false; |
508 | } | 508 | } |
509 | 509 | ||
510 | bool create_dir(void) | ||
511 | { | ||
512 | char dirname[MAX_PATH]; | ||
513 | char *cwd; | ||
514 | int rc; | ||
515 | int pathlen; | ||
516 | |||
517 | cwd = getcwd(NULL, 0); | ||
518 | memset(dirname, 0, sizeof dirname); | ||
519 | |||
520 | snprintf(dirname, sizeof dirname, "%s/", | ||
521 | cwd[1] ? cwd : ""); | ||
522 | |||
523 | pathlen = strlen(dirname); | ||
524 | rc = kbd_input(dirname + pathlen, (sizeof dirname)-pathlen); | ||
525 | if(rc < 0) | ||
526 | return false; | ||
527 | |||
528 | rc = mkdir(dirname, 0); | ||
529 | if(rc < 0) { | ||
530 | splash(HZ, true, "%s %s", str(LANG_CREATE_DIR), str(LANG_FAILED)); | ||
531 | } else { | ||
532 | onplay_result = ONPLAY_RELOAD_DIR; | ||
533 | } | ||
534 | |||
535 | return true; | ||
536 | } | ||
537 | |||
510 | int onplay(char* file, int attr) | 538 | int onplay(char* file, int attr) |
511 | { | 539 | { |
512 | struct menu_items menu[5]; /* increase this if you add entries! */ | 540 | struct menu_items menu[5]; /* increase this if you add entries! */ |
@@ -514,36 +542,43 @@ int onplay(char* file, int attr) | |||
514 | 542 | ||
515 | onplay_result = ONPLAY_OK; | 543 | onplay_result = ONPLAY_OK; |
516 | 544 | ||
517 | selected_file = file; | 545 | if(file) |
518 | selected_file_attr = attr; | ||
519 | |||
520 | if (((attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) || | ||
521 | (attr & ATTR_DIRECTORY) || | ||
522 | ((attr & TREE_ATTR_MASK) == TREE_ATTR_M3U)) | ||
523 | { | 546 | { |
524 | menu[i].desc = str(LANG_PLAYINDICES_PLAYLIST); | 547 | selected_file = file; |
525 | menu[i].function = playlist_options; | 548 | selected_file_attr = attr; |
549 | |||
550 | if (((attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) || | ||
551 | (attr & ATTR_DIRECTORY) || | ||
552 | ((attr & TREE_ATTR_MASK) == TREE_ATTR_M3U)) | ||
553 | { | ||
554 | menu[i].desc = str(LANG_PLAYINDICES_PLAYLIST); | ||
555 | menu[i].function = playlist_options; | ||
556 | i++; | ||
557 | } | ||
558 | |||
559 | menu[i].desc = str(LANG_RENAME); | ||
560 | menu[i].function = rename_file; | ||
526 | i++; | 561 | i++; |
562 | |||
563 | if (!(attr & ATTR_DIRECTORY)) | ||
564 | { | ||
565 | menu[i].desc = str(LANG_DELETE); | ||
566 | menu[i].function = delete_file; | ||
567 | i++; | ||
568 | } | ||
569 | |||
570 | if ((attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) | ||
571 | { | ||
572 | menu[i].desc = str(LANG_VBRFIX); | ||
573 | menu[i].function = vbr_fix; | ||
574 | i++; | ||
575 | } | ||
527 | } | 576 | } |
528 | 577 | ||
529 | menu[i].desc = str(LANG_RENAME); | 578 | menu[i].desc = str(LANG_CREATE_DIR); |
530 | menu[i].function = rename_file; | 579 | menu[i].function = create_dir; |
531 | i++; | 580 | i++; |
532 | 581 | ||
533 | if (!(attr & ATTR_DIRECTORY)) | ||
534 | { | ||
535 | menu[i].desc = str(LANG_DELETE); | ||
536 | menu[i].function = delete_file; | ||
537 | i++; | ||
538 | } | ||
539 | |||
540 | if ((attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) | ||
541 | { | ||
542 | menu[i].desc = str(LANG_VBRFIX); | ||
543 | menu[i].function = vbr_fix; | ||
544 | i++; | ||
545 | } | ||
546 | |||
547 | /* DIY menu handling, since we want to exit after selection */ | 582 | /* DIY menu handling, since we want to exit after selection */ |
548 | m = menu_init( menu, i ); | 583 | m = menu_init( menu, i ); |
549 | result = menu_show(m); | 584 | result = menu_show(m); |