diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/bookmark.c | 50 |
1 files changed, 15 insertions, 35 deletions
diff --git a/apps/bookmark.c b/apps/bookmark.c index 0c12026816..f052a6600c 100644 --- a/apps/bookmark.c +++ b/apps/bookmark.c | |||
@@ -60,9 +60,7 @@ static void display_bookmark(char* bookmark, | |||
60 | int bookmark_count); | 60 | int bookmark_count); |
61 | static void say_bookmark(char* bookmark, | 61 | static void say_bookmark(char* bookmark, |
62 | int bookmark_id); | 62 | int bookmark_id); |
63 | static bool generate_bookmark_file_name(char *in, | 63 | static bool generate_bookmark_file_name(char *in); |
64 | char *out, | ||
65 | unsigned int max_length); | ||
66 | static char* get_bookmark(char* bookmark_file, int bookmark_count); | 64 | static char* get_bookmark(char* bookmark_file, int bookmark_count); |
67 | static bool parse_bookmark(char *bookmark, | 65 | static bool parse_bookmark(char *bookmark, |
68 | int *resume_index, | 66 | int *resume_index, |
@@ -147,9 +145,7 @@ static bool bookmark_load_menu(void) | |||
147 | { | 145 | { |
148 | char* name = playlist_get_name(NULL, global_temp_buffer, | 146 | char* name = playlist_get_name(NULL, global_temp_buffer, |
149 | sizeof(global_temp_buffer)); | 147 | sizeof(global_temp_buffer)); |
150 | if (generate_bookmark_file_name(name, | 148 | if (generate_bookmark_file_name(name)) |
151 | global_bookmark_file_name, | ||
152 | sizeof(global_bookmark_file_name))) | ||
153 | { | 149 | { |
154 | bookmark = select_bookmark(global_bookmark_file_name); | 150 | bookmark = select_bookmark(global_bookmark_file_name); |
155 | if (!bookmark) | 151 | if (!bookmark) |
@@ -319,9 +315,7 @@ static bool write_bookmark(bool create_bookmark_file) | |||
319 | { | 315 | { |
320 | char* name = playlist_get_name(NULL, global_temp_buffer, | 316 | char* name = playlist_get_name(NULL, global_temp_buffer, |
321 | sizeof(global_temp_buffer)); | 317 | sizeof(global_temp_buffer)); |
322 | if (generate_bookmark_file_name(name, | 318 | if (generate_bookmark_file_name(name)) |
323 | global_bookmark_file_name, | ||
324 | sizeof(global_bookmark_file_name))) | ||
325 | { | 319 | { |
326 | success = add_bookmark(global_bookmark_file_name, bookmark); | 320 | success = add_bookmark(global_bookmark_file_name, bookmark); |
327 | } | 321 | } |
@@ -475,9 +469,7 @@ bool bookmark_autoload(char* file) | |||
475 | return false; | 469 | return false; |
476 | 470 | ||
477 | /*Checking to see if a bookmark file exists.*/ | 471 | /*Checking to see if a bookmark file exists.*/ |
478 | if(!generate_bookmark_file_name(file, | 472 | if(!generate_bookmark_file_name(file)) |
479 | global_bookmark_file_name, | ||
480 | sizeof(global_bookmark_file_name))) | ||
481 | { | 473 | { |
482 | return false; | 474 | return false; |
483 | } | 475 | } |
@@ -1109,33 +1101,21 @@ static bool parse_bookmark(char *bookmark, | |||
1109 | /* it would be here that the centralized/decentralized bookmark code */ | 1101 | /* it would be here that the centralized/decentralized bookmark code */ |
1110 | /* could be placed. */ | 1102 | /* could be placed. */ |
1111 | /* ----------------------------------------------------------------------- */ | 1103 | /* ----------------------------------------------------------------------- */ |
1112 | static bool generate_bookmark_file_name(char *in, char *out, | 1104 | static bool generate_bookmark_file_name(char *in) |
1113 | unsigned int max_length) | ||
1114 | { | 1105 | { |
1115 | char* cp; | 1106 | int len = strlen(in); |
1116 | 1107 | ||
1117 | if (!in || !out || max_length <= 0) | 1108 | /* if this is a root dir MP3, rename the bookmark file root_dir.bmark */ |
1118 | return false; | ||
1119 | |||
1120 | if (max_length < strlen(in)+6) | ||
1121 | return false; | ||
1122 | |||
1123 | /* if this is a root dir MP3, rename the boomark file root_dir.bmark */ | ||
1124 | /* otherwise, name it based on the in variable */ | 1109 | /* otherwise, name it based on the in variable */ |
1125 | cp = in; | 1110 | if (!strcmp("/", in)) |
1126 | 1111 | strcpy(global_bookmark_file_name, "/root_dir.bmark"); | |
1127 | cp = in + strlen(in) - 1; | ||
1128 | if (*cp == '/') | ||
1129 | *cp = 0; | ||
1130 | |||
1131 | cp = in; | ||
1132 | if (*cp == '/') | ||
1133 | cp++; | ||
1134 | |||
1135 | if (strlen(in) > 0) | ||
1136 | snprintf(out, max_length, "/%s.%s", cp, "bmark"); | ||
1137 | else | 1112 | else |
1138 | snprintf(out, max_length, "/root_dir.%s", "bmark"); | 1113 | { |
1114 | strcpy(global_bookmark_file_name, in); | ||
1115 | if(global_bookmark_file_name[len-1] == '/') | ||
1116 | len--; | ||
1117 | strcpy(&global_bookmark_file_name[len], ".bmark"); | ||
1118 | } | ||
1139 | 1119 | ||
1140 | return true; | 1120 | return true; |
1141 | } | 1121 | } |