summaryrefslogtreecommitdiff
path: root/apps/recorder
diff options
context:
space:
mode:
Diffstat (limited to 'apps/recorder')
-rw-r--r--apps/recorder/radio.c3
-rw-r--r--apps/recorder/recording.c47
-rw-r--r--apps/recorder/recording.h1
3 files changed, 32 insertions, 19 deletions
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c
index af39124b9b..feea3fa5f2 100644
--- a/apps/recorder/radio.c
+++ b/apps/recorder/radio.c
@@ -155,6 +155,9 @@ bool radio_screen(void)
155 155
156 radio_load_presets(); 156 radio_load_presets();
157 157
158 if(rec_create_directory() > 0)
159 have_recorded = true;
160
158 mpeg_stop(); 161 mpeg_stop();
159 162
160 mpeg_init_recording(); 163 mpeg_init_recording();
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index 1a0215e5e2..2cef11ae13 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -137,6 +137,32 @@ char *rec_create_filename(char *buffer)
137 return buffer; 137 return buffer;
138} 138}
139 139
140int rec_create_directory(void)
141{
142 int rc;
143
144 /* Try to create the base directory if needed */
145 if(global_settings.rec_directory == 0)
146 {
147 rc = mkdir(rec_base_directory, 0);
148 if(rc < 0 && errno != EEXIST)
149 {
150 splash(HZ * 2, true,
151 "Can't create the %s directory. Error code %d.",
152 rec_base_directory, rc);
153 return -1;
154 }
155 else
156 {
157 /* If we have created the directory, we want the dir browser to
158 be refreshed even if we haven't recorded anything */
159 if(errno != EEXIST)
160 return 1;
161 }
162 }
163 return 0;
164}
165
140bool recording_screen(void) 166bool recording_screen(void)
141{ 167{
142 int button; 168 int button;
@@ -152,7 +178,6 @@ bool recording_screen(void)
152 unsigned int last_seconds = 0; 178 unsigned int last_seconds = 0;
153 int hours, minutes; 179 int hours, minutes;
154 char path_buffer[MAX_PATH]; 180 char path_buffer[MAX_PATH];
155 int rc;
156 bool been_in_usb_mode = false; 181 bool been_in_usb_mode = false;
157 182
158 cursor = 0; 183 cursor = 0;
@@ -183,24 +208,8 @@ bool recording_screen(void)
183 lcd_getstringsize("M", &w, &h); 208 lcd_getstringsize("M", &w, &h);
184 lcd_setmargins(global_settings.invert_cursor ? 0 : w, 8); 209 lcd_setmargins(global_settings.invert_cursor ? 0 : w, 8);
185 210
186 /* Try to create the base directory if needed */ 211 if(rec_create_directory() > 0)
187 if(global_settings.rec_directory == 0) 212 have_recorded = true;
188 {
189 rc = mkdir(rec_base_directory, 0);
190 if(rc < 0 && errno != EEXIST)
191 {
192 splash(HZ * 2, true,
193 "Can't create the %s directory. Error code %d.",
194 rec_base_directory, rc);
195 }
196 else
197 {
198 /* If we have created the directory, we want the dir browser to
199 be refreshed even if we haven't recorded anything */
200 if(errno != EEXIST)
201 have_recorded = true;
202 }
203 }
204 213
205 while(!done) 214 while(!done)
206 { 215 {
diff --git a/apps/recorder/recording.h b/apps/recorder/recording.h
index 174621b3b7..384b34f5bf 100644
--- a/apps/recorder/recording.h
+++ b/apps/recorder/recording.h
@@ -21,5 +21,6 @@
21 21
22bool recording_screen(void); 22bool recording_screen(void);
23char *rec_create_filename(char *buf); 23char *rec_create_filename(char *buf);
24int rec_create_directory(void);
24 25
25#endif 26#endif