diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2007-07-10 07:41:37 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2007-07-10 07:41:37 +0000 |
commit | 415e9d78cce1c07f17b4c643eb1b0d2ef1622706 (patch) | |
tree | 46ccafcbfc4003b145704a39bbdb270b3a65cded /apps/recorder/recording.c | |
parent | 1c2de0a45e17fbd5af3cab98ad2b1bc70a801d84 (diff) | |
download | rockbox-415e9d78cce1c07f17b4c643eb1b0d2ef1622706.tar.gz rockbox-415e9d78cce1c07f17b4c643eb1b0d2ef1622706.zip |
User configurable recording path (my patch in FS#7201). path defaults to / and can be changed in the folder context menu (cleared in the recording settings menu)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13838 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/recorder/recording.c')
-rw-r--r-- | apps/recorder/recording.c | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c index 17ed1052cb..a085bbbc03 100644 --- a/apps/recorder/recording.c +++ b/apps/recorder/recording.c | |||
@@ -508,15 +508,27 @@ static void adjust_cursor(void) | |||
508 | cursor = max_cursor; | 508 | cursor = max_cursor; |
509 | } | 509 | } |
510 | 510 | ||
511 | static bool check_dir(char *folder) | ||
512 | { | ||
513 | DIR *dir = opendir(folder); | ||
514 | if (!dir && strcmp(folder, "/")) | ||
515 | { | ||
516 | int rc = mkdir(folder); | ||
517 | if(rc < 0) | ||
518 | return false; | ||
519 | return true; | ||
520 | } | ||
521 | closedir(dir); | ||
522 | return true; | ||
523 | } | ||
524 | |||
511 | char *rec_create_filename(char *buffer) | 525 | char *rec_create_filename(char *buffer) |
512 | { | 526 | { |
513 | char ext[16]; | 527 | char ext[16]; |
514 | 528 | strcpy(buffer,global_settings.rec_directory); | |
515 | if(global_settings.rec_directory) | 529 | if (!check_dir(buffer)) |
516 | getcwd(buffer, MAX_PATH); | 530 | return NULL; |
517 | else | 531 | |
518 | strncpy(buffer, rec_base_directory, MAX_PATH); | ||
519 | |||
520 | snprintf(ext, sizeof(ext), ".%s", | 532 | snprintf(ext, sizeof(ext), ".%s", |
521 | REC_FILE_ENDING(global_settings.rec_format)); | 533 | REC_FILE_ENDING(global_settings.rec_format)); |
522 | 534 | ||
@@ -542,28 +554,7 @@ void rec_init_filename(void) | |||
542 | 554 | ||
543 | int rec_create_directory(void) | 555 | int rec_create_directory(void) |
544 | { | 556 | { |
545 | int rc; | 557 | return check_dir(global_settings.rec_directory)?1:0; |
546 | |||
547 | /* Try to create the base directory if needed */ | ||
548 | if(global_settings.rec_directory == 0) | ||
549 | { | ||
550 | rc = mkdir(rec_base_directory); | ||
551 | if(rc < 0 && errno != EEXIST) | ||
552 | { | ||
553 | gui_syncsplash(HZ * 2, | ||
554 | "Can't create the %s directory. Error code %d.", | ||
555 | rec_base_directory, rc); | ||
556 | return -1; | ||
557 | } | ||
558 | else | ||
559 | { | ||
560 | /* If we have created the directory, we want the dir browser to | ||
561 | be refreshed even if we haven't recorded anything */ | ||
562 | if(errno != EEXIST) | ||
563 | return 1; | ||
564 | } | ||
565 | } | ||
566 | return 0; | ||
567 | } | 558 | } |
568 | 559 | ||
569 | void rec_init_recording_options(struct audio_recording_options *options) | 560 | void rec_init_recording_options(struct audio_recording_options *options) |
@@ -747,7 +738,16 @@ bool recording_screen(bool no_source) | |||
747 | }; | 738 | }; |
748 | 739 | ||
749 | struct audio_recording_options rec_options; | 740 | struct audio_recording_options rec_options; |
750 | 741 | if (check_dir(global_settings.rec_directory) == false) | |
742 | { | ||
743 | do { | ||
744 | gui_syncsplash(0, "%s %s", | ||
745 | str(LANG_REC_DIR_NOT_WRITABLE), | ||
746 | str(LANG_OFF_ABORT)); | ||
747 | } while (action_userabort(HZ) == false); | ||
748 | return false; | ||
749 | } | ||
750 | |||
751 | rec_status = RCSTAT_IN_RECSCREEN; | 751 | rec_status = RCSTAT_IN_RECSCREEN; |
752 | cursor = 0; | 752 | cursor = 0; |
753 | #if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR) | 753 | #if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR) |