diff options
author | Teruaki Kawashima <teru@rockbox.org> | 2010-10-22 12:50:14 +0000 |
---|---|---|
committer | Teruaki Kawashima <teru@rockbox.org> | 2010-10-22 12:50:14 +0000 |
commit | 368e89e3bc88446c8fac3d5cfca266061f4e77fb (patch) | |
tree | cf79403e4923e09c5801454077d8fc17685efe1d /apps | |
parent | 082c7d3c6b6a868efb4340c34918e7aa2114f07f (diff) | |
download | rockbox-368e89e3bc88446c8fac3d5cfca266061f4e77fb.tar.gz rockbox-368e89e3bc88446c8fac3d5cfca266061f4e77fb.zip |
simplify rockbox_browse a bit and reuse buffer.
use const for argument of set_current_file.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28328 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/playlist_catalog.c | 4 | ||||
-rw-r--r-- | apps/plugin.h | 2 | ||||
-rw-r--r-- | apps/tree.c | 35 | ||||
-rw-r--r-- | apps/tree.h | 2 |
4 files changed, 16 insertions, 27 deletions
diff --git a/apps/playlist_catalog.c b/apps/playlist_catalog.c index ef44e36ba7..5f9f46728a 100644 --- a/apps/playlist_catalog.c +++ b/apps/playlist_catalog.c | |||
@@ -70,7 +70,9 @@ static int initialize_catalog(void) | |||
70 | bool default_dir = true; | 70 | bool default_dir = true; |
71 | 71 | ||
72 | /* directory config is of the format: "dir: /path/to/dir" */ | 72 | /* directory config is of the format: "dir: /path/to/dir" */ |
73 | if (global_settings.playlist_catalog_dir[0]) | 73 | if (global_settings.playlist_catalog_dir[0] && |
74 | strcmp(global_settings.playlist_catalog_dir, | ||
75 | PLAYLIST_CATALOG_DEFAULT_DIR)) | ||
74 | { | 76 | { |
75 | strcpy(playlist_dir, global_settings.playlist_catalog_dir); | 77 | strcpy(playlist_dir, global_settings.playlist_catalog_dir); |
76 | default_dir = false; | 78 | default_dir = false; |
diff --git a/apps/plugin.h b/apps/plugin.h index faea8470f0..56e0bfcd04 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -831,7 +831,7 @@ struct plugin_api { | |||
831 | #endif | 831 | #endif |
832 | int (*show_logo)(void); | 832 | int (*show_logo)(void); |
833 | struct tree_context* (*tree_get_context)(void); | 833 | struct tree_context* (*tree_get_context)(void); |
834 | void (*set_current_file)(char* path); | 834 | void (*set_current_file)(const char* path); |
835 | void (*set_dirfilter)(int l_dirfilter); | 835 | void (*set_dirfilter)(int l_dirfilter); |
836 | 836 | ||
837 | #ifdef HAVE_WHEEL_POSITION | 837 | #ifdef HAVE_WHEEL_POSITION |
diff --git a/apps/tree.c b/apps/tree.c index 01a00d1f40..86238c50d9 100644 --- a/apps/tree.c +++ b/apps/tree.c | |||
@@ -563,9 +563,9 @@ void set_dirfilter(int l_dirfilter) | |||
563 | } | 563 | } |
564 | 564 | ||
565 | /* Selects a file and update tree context properly */ | 565 | /* Selects a file and update tree context properly */ |
566 | void set_current_file(char *path) | 566 | void set_current_file(const char *path) |
567 | { | 567 | { |
568 | char *name; | 568 | const char *name; |
569 | int i; | 569 | int i; |
570 | 570 | ||
571 | #ifdef HAVE_TAGCACHE | 571 | #ifdef HAVE_TAGCACHE |
@@ -580,9 +580,7 @@ void set_current_file(char *path) | |||
580 | name = strrchr(path+1,'/'); | 580 | name = strrchr(path+1,'/'); |
581 | if (name) | 581 | if (name) |
582 | { | 582 | { |
583 | *name = 0; | 583 | strlcpy(tc.currdir, path, name - path + 1); |
584 | strcpy(tc.currdir, path); | ||
585 | *name = '/'; | ||
586 | name++; | 584 | name++; |
587 | } | 585 | } |
588 | else | 586 | else |
@@ -929,6 +927,7 @@ bool create_playlist(void) | |||
929 | 927 | ||
930 | int rockbox_browse(const char *root, int dirfilter) | 928 | int rockbox_browse(const char *root, int dirfilter) |
931 | { | 929 | { |
930 | static char current[MAX_PATH]; | ||
932 | int ret_val = 0; | 931 | int ret_val = 0; |
933 | int *last_filter = tc.dirfilter; | 932 | int *last_filter = tc.dirfilter; |
934 | tc.dirfilter = &dirfilter; | 933 | tc.dirfilter = &dirfilter; |
@@ -939,7 +938,7 @@ int rockbox_browse(const char *root, int dirfilter) | |||
939 | { | 938 | { |
940 | static struct tree_context backup; | 939 | static struct tree_context backup; |
941 | int last_context; | 940 | int last_context; |
942 | const char *dir, *ext, *setting = NULL; | 941 | const char *ext, *setting; |
943 | 942 | ||
944 | backup = tc; | 943 | backup = tc; |
945 | tc.selected_item = 0; | 944 | tc.selected_item = 0; |
@@ -952,7 +951,6 @@ int rockbox_browse(const char *root, int dirfilter) | |||
952 | switch(dirfilter) | 951 | switch(dirfilter) |
953 | { | 952 | { |
954 | case SHOW_LNG: | 953 | case SHOW_LNG: |
955 | dir = LANG_DIR; | ||
956 | ext = "lng"; | 954 | ext = "lng"; |
957 | if (global_settings.lang_file[0]) | 955 | if (global_settings.lang_file[0]) |
958 | setting = global_settings.lang_file; | 956 | setting = global_settings.lang_file; |
@@ -960,24 +958,20 @@ int rockbox_browse(const char *root, int dirfilter) | |||
960 | setting = "english"; | 958 | setting = "english"; |
961 | break; | 959 | break; |
962 | case SHOW_WPS: | 960 | case SHOW_WPS: |
963 | dir = WPS_DIR; | ||
964 | ext = "wps"; | 961 | ext = "wps"; |
965 | setting = global_settings.wps_file; | 962 | setting = global_settings.wps_file; |
966 | break; | 963 | break; |
967 | #ifdef HAVE_REMOTE_LCD | 964 | #ifdef HAVE_REMOTE_LCD |
968 | case SHOW_RWPS: | 965 | case SHOW_RWPS: |
969 | dir = WPS_DIR; | ||
970 | ext = "rwps"; | 966 | ext = "rwps"; |
971 | setting = global_settings.rwps_file; | 967 | setting = global_settings.rwps_file; |
972 | break; | 968 | break; |
973 | case SHOW_RSBS: | 969 | case SHOW_RSBS: |
974 | dir = WPS_DIR; | ||
975 | ext = "rsbs"; | 970 | ext = "rsbs"; |
976 | setting = global_settings.rsbs_file; | 971 | setting = global_settings.rsbs_file; |
977 | break; | 972 | break; |
978 | #if CONFIG_TUNER | 973 | #if CONFIG_TUNER |
979 | case SHOW_RFMS: | 974 | case SHOW_RFMS: |
980 | dir = WPS_DIR; | ||
981 | ext = "rfms"; | 975 | ext = "rfms"; |
982 | setting = global_settings.rfms_file; | 976 | setting = global_settings.rfms_file; |
983 | break; | 977 | break; |
@@ -985,18 +979,15 @@ int rockbox_browse(const char *root, int dirfilter) | |||
985 | #endif | 979 | #endif |
986 | #ifdef HAVE_LCD_BITMAP | 980 | #ifdef HAVE_LCD_BITMAP |
987 | case SHOW_FONT: | 981 | case SHOW_FONT: |
988 | dir = FONT_DIR; | ||
989 | ext = "fnt"; | 982 | ext = "fnt"; |
990 | setting = global_settings.font_file; | 983 | setting = global_settings.font_file; |
991 | break; | 984 | break; |
992 | case SHOW_SBS: | 985 | case SHOW_SBS: |
993 | dir = WPS_DIR; | ||
994 | ext = "sbs"; | 986 | ext = "sbs"; |
995 | setting = global_settings.sbs_file; | 987 | setting = global_settings.sbs_file; |
996 | break; | 988 | break; |
997 | #if CONFIG_TUNER | 989 | #if CONFIG_TUNER |
998 | case SHOW_FMS: | 990 | case SHOW_FMS: |
999 | dir = WPS_DIR; | ||
1000 | ext = "fms"; | 991 | ext = "fms"; |
1001 | setting = global_settings.fms_file; | 992 | setting = global_settings.fms_file; |
1002 | break; | 993 | break; |
@@ -1004,23 +995,20 @@ int rockbox_browse(const char *root, int dirfilter) | |||
1004 | #endif | 995 | #endif |
1005 | #if CONFIG_TUNER | 996 | #if CONFIG_TUNER |
1006 | case SHOW_FMR: | 997 | case SHOW_FMR: |
1007 | dir = FMPRESET_PATH; | ||
1008 | ext = "fmr"; | 998 | ext = "fmr"; |
1009 | setting = global_settings.fmr_file; | 999 | setting = global_settings.fmr_file; |
1010 | break; | 1000 | break; |
1011 | #endif | 1001 | #endif |
1012 | default: | 1002 | default: |
1013 | dir = ext = setting = NULL; | 1003 | ext = setting = NULL; |
1014 | break; | 1004 | break; |
1015 | } | 1005 | } |
1016 | 1006 | ||
1017 | /* If we've found a file to center on, do it */ | 1007 | /* If we've found a file to center on, do it */ |
1018 | if (setting) | 1008 | if (setting) |
1019 | { | 1009 | { |
1020 | char current[MAX_PATH], _dir[MAX_PATH]; | 1010 | /* if setting != NULL, ext is initialized */ |
1021 | /* if setting != NULL, ext and dir are not used uninitialized */ | 1011 | snprintf(current, sizeof(current), "%s/%s.%s", root, setting, ext); |
1022 | snprintf(current, sizeof(current), "%s/%s.%s", | ||
1023 | get_user_file_path(dir, 0, _dir, sizeof(_dir)), setting, ext); | ||
1024 | set_current_file(current); | 1012 | set_current_file(current); |
1025 | /* set_current_file changes dirlevel, change it back */ | 1013 | /* set_current_file changes dirlevel, change it back */ |
1026 | tc.dirlevel = 0; | 1014 | tc.dirlevel = 0; |
@@ -1032,11 +1020,10 @@ int rockbox_browse(const char *root, int dirfilter) | |||
1032 | } | 1020 | } |
1033 | else | 1021 | else |
1034 | { | 1022 | { |
1035 | static char buf[MAX_PATH]; | ||
1036 | if (dirfilter != SHOW_ID3DB) | 1023 | if (dirfilter != SHOW_ID3DB) |
1037 | tc.dirfilter = &global_settings.dirfilter; | 1024 | tc.dirfilter = &global_settings.dirfilter; |
1038 | strcpy(buf,root); | 1025 | strcpy(current,root); |
1039 | set_current_file(buf); | 1026 | set_current_file(current); |
1040 | ret_val = dirbrowse(); | 1027 | ret_val = dirbrowse(); |
1041 | } | 1028 | } |
1042 | tc.dirfilter = last_filter; | 1029 | tc.dirfilter = last_filter; |
diff --git a/apps/tree.h b/apps/tree.h index 993d1b4569..a74960f7a5 100644 --- a/apps/tree.h +++ b/apps/tree.h | |||
@@ -75,7 +75,7 @@ void tree_mem_init(void) INIT_ATTR; | |||
75 | void tree_gui_init(void) INIT_ATTR; | 75 | void tree_gui_init(void) INIT_ATTR; |
76 | char* get_current_file(char* buffer, size_t buffer_len); | 76 | char* get_current_file(char* buffer, size_t buffer_len); |
77 | void set_dirfilter(int l_dirfilter); | 77 | void set_dirfilter(int l_dirfilter); |
78 | void set_current_file(char *path); | 78 | void set_current_file(const char *path); |
79 | int rockbox_browse(const char *root, int dirfilter); | 79 | int rockbox_browse(const char *root, int dirfilter); |
80 | bool create_playlist(void); | 80 | bool create_playlist(void); |
81 | void resume_directory(const char *dir); | 81 | void resume_directory(const char *dir); |