summaryrefslogtreecommitdiff
path: root/apps/recorder/recording.c
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-09-02 01:15:35 +0000
committerJens Arnold <amiconn@rockbox.org>2005-09-02 01:15:35 +0000
commit58e9412bff9947e4514c0d55152bfad91049a60c (patch)
treedc4cc3d7812388805c07c08d4cd9271eecab938e /apps/recorder/recording.c
parentc7240cf844d7c2a28031aa5ec984f0e007de242d (diff)
downloadrockbox-58e9412bff9947e4514c0d55152bfad91049a60c.tar.gz
rockbox-58e9412bff9947e4514c0d55152bfad91049a60c.zip
Added universal functions for creation of numbered filenames and date+time filenames (units with RTC only). Some size optimisations within code using these new functions. Everything should behave as before, except config saving will always find the highest file number + 1 even if the sequence is non-contiguous.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7449 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/recorder/recording.c')
-rw-r--r--apps/recorder/recording.c47
1 files changed, 3 insertions, 44 deletions
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index ea71538322..3fcf97b177 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -164,56 +164,15 @@ void adjust_cursor(void)
164 164
165char *rec_create_filename(char *buffer) 165char *rec_create_filename(char *buffer)
166{ 166{
167 int fpos;
168
169 if(global_settings.rec_directory) 167 if(global_settings.rec_directory)
170 getcwd(buffer, MAX_PATH); 168 getcwd(buffer, MAX_PATH);
171 else 169 else
172 strncpy(buffer, rec_base_directory, MAX_PATH); 170 strncpy(buffer, rec_base_directory, MAX_PATH);
173 171
174 fpos = strlen(buffer); 172#ifdef HAVE_RTC
175#ifdef HAVE_RTC 173 create_datetime_filename(buffer, buffer, "R", ".mp3");
176 {
177 struct tm *tm = get_time();
178
179 /* Append filename to path: RYYMMDD-HH.MM.SS.mp3 */
180 snprintf(&buffer[fpos], MAX_PATH-fpos,
181 "/R%02d%02d%02d-%02d%02d%02d.mp3",
182 tm->tm_year%100, tm->tm_mon+1, tm->tm_mday,
183 tm->tm_hour, tm->tm_min, tm->tm_sec);
184 }
185#else 174#else
186 { 175 create_numbered_filename(buffer, buffer, "rec_", ".mp3", 4);
187 DIR* dir;
188 int max_rec_file = 1; /* default to rec_0001.mp3 */
189 dir = opendir(buffer);
190 if (dir) /* found */
191 {
192 /* Search for the highest recording filename present,
193 increment behind that. So even with "holes"
194 (deleted recordings), the newest will always have the
195 highest number. */
196 while(true)
197 {
198 struct dirent* entry;
199 int curr_rec_file;
200 /* walk through the directory content */
201 entry = readdir(dir);
202 if (!entry)
203 {
204 closedir(dir);
205 break; /* end of dir */
206 }
207 if (strncasecmp(entry->d_name, "rec_", 4))
208 continue; /* no recording file */
209 curr_rec_file = atoi(&entry->d_name[4]);
210 if (curr_rec_file >= max_rec_file)
211 max_rec_file = curr_rec_file + 1;
212 }
213 }
214 snprintf(&buffer[fpos], MAX_PATH-fpos,
215 "/rec_%04d.mp3", max_rec_file);
216 }
217#endif 176#endif
218 return buffer; 177 return buffer;
219} 178}