diff options
author | Jörg Hohensohn <hohensoh@rockbox.org> | 2004-10-17 10:00:46 +0000 |
---|---|---|
committer | Jörg Hohensohn <hohensoh@rockbox.org> | 2004-10-17 10:00:46 +0000 |
commit | 1120ef50c72920bdcd20ccd42477473b98fda452 (patch) | |
tree | 36367d85466211c0b80928c35ca7d0036a9658e0 | |
parent | 954e5888b15d9680129f89aaffa161687fede01b (diff) | |
download | rockbox-1120ef50c72920bdcd20ccd42477473b98fda452.tar.gz rockbox-1120ef50c72920bdcd20ccd42477473b98fda452.zip |
file name generation for recorder without RTC (Ondio)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5298 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/recorder/recording.c | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c index 73c7f78509..662b0797d7 100644 --- a/apps/recorder/recording.c +++ b/apps/recorder/recording.c | |||
@@ -48,6 +48,7 @@ | |||
48 | #include "dir.h" | 48 | #include "dir.h" |
49 | #include "errno.h" | 49 | #include "errno.h" |
50 | #include "talk.h" | 50 | #include "talk.h" |
51 | #include "atoi.h" | ||
51 | 52 | ||
52 | #ifdef HAVE_RECORDING | 53 | #ifdef HAVE_RECORDING |
53 | 54 | ||
@@ -149,18 +150,53 @@ void adjust_cursor(void) | |||
149 | char *rec_create_filename(char *buffer) | 150 | char *rec_create_filename(char *buffer) |
150 | { | 151 | { |
151 | int fpos; | 152 | int fpos; |
152 | struct tm *tm = get_time(); | ||
153 | 153 | ||
154 | if(global_settings.rec_directory) | 154 | if(global_settings.rec_directory) |
155 | getcwd(buffer, MAX_PATH); | 155 | getcwd(buffer, MAX_PATH); |
156 | else | 156 | else |
157 | strncpy(buffer, rec_base_directory, MAX_PATH); | 157 | strncpy(buffer, rec_base_directory, MAX_PATH); |
158 | 158 | ||
159 | /* Append filename to path: RYYMMDD-HH.MM.SS.mp3 */ | ||
160 | fpos = strlen(buffer); | 159 | fpos = strlen(buffer); |
161 | snprintf(&buffer[fpos], MAX_PATH-fpos, "/R%02d%02d%02d-%02d%02d%02d.mp3", | 160 | #ifdef HAVE_RTC |
162 | tm->tm_year%100, tm->tm_mon+1, tm->tm_mday, | 161 | { |
163 | tm->tm_hour, tm->tm_min, tm->tm_sec); | 162 | struct tm *tm = get_time(); |
163 | |||
164 | /* Append filename to path: RYYMMDD-HH.MM.SS.mp3 */ | ||
165 | snprintf(&buffer[fpos], MAX_PATH-fpos, | ||
166 | "/R%02d%02d%02d-%02d%02d%02d.mp3", | ||
167 | tm->tm_year%100, tm->tm_mon+1, tm->tm_mday, | ||
168 | tm->tm_hour, tm->tm_min, tm->tm_sec); | ||
169 | } | ||
170 | #else | ||
171 | { | ||
172 | DIR* dir; | ||
173 | int max_rec_file = 1; /* default to rec_0001.mp3 */ | ||
174 | dir = opendir(buffer); | ||
175 | if (dir) /* found */ | ||
176 | { | ||
177 | /* Search for the highest recording filename present, | ||
178 | increment behind that. So even with "holes" | ||
179 | (deleted recordings), the newest will always have the | ||
180 | highest number. */ | ||
181 | while(true) | ||
182 | { | ||
183 | struct dirent* entry; | ||
184 | int curr_rec_file; | ||
185 | /* walk through the directory content */ | ||
186 | entry = readdir(dir); | ||
187 | if (!entry) | ||
188 | break; /* end of dir */ | ||
189 | if (strncasecmp(entry->d_name, "rec_", 4)) | ||
190 | continue; /* no recording file */ | ||
191 | curr_rec_file = atoi(&entry->d_name[4]); | ||
192 | if (curr_rec_file >= max_rec_file) | ||
193 | max_rec_file = curr_rec_file + 1; | ||
194 | } | ||
195 | } | ||
196 | snprintf(&buffer[fpos], MAX_PATH-fpos, | ||
197 | "/rec_%04d.mp3", max_rec_file); | ||
198 | } | ||
199 | #endif | ||
164 | return buffer; | 200 | return buffer; |
165 | } | 201 | } |
166 | 202 | ||