summaryrefslogtreecommitdiff
path: root/apps/recorder/recording.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/recorder/recording.c')
-rw-r--r--apps/recorder/recording.c58
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
511static 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
511char *rec_create_filename(char *buffer) 525char *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
543int rec_create_directory(void) 555int 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
569void rec_init_recording_options(struct audio_recording_options *options) 560void 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)