summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-08-22 15:47:30 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-08-22 15:47:30 +0000
commit053d904645885f3e4003071bb54c649ee5aa26e7 (patch)
tree7764e51de2325455610e99f8be2b504d42f534fb
parentc94aa3273106c1b016d6007a8b3c2c529caf136a (diff)
downloadrockbox-053d904645885f3e4003071bb54c649ee5aa26e7.tar.gz
rockbox-053d904645885f3e4003071bb54c649ee5aa26e7.zip
Bill Napier's patch slightly remodelled. This adds a setting called
"Show hidden files" that if enabled will show files with the hidden attribute and/or starting with a dot in the dir browser. If the setting is set to Off, files/dirs starting with a dot or that have the hidden attribute set will be... yes, hidden. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1926 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/settings.c5
-rw-r--r--apps/settings.h4
-rw-r--r--apps/settings_menu.c6
-rw-r--r--apps/tree.c36
4 files changed, 43 insertions, 8 deletions
diff --git a/apps/settings.c b/apps/settings.c
index afd9840b2a..11a4647447 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -259,7 +259,8 @@ int settings_save( void )
259 ((global_settings.mp3filter & 1) << 1) | 259 ((global_settings.mp3filter & 1) << 1) |
260 ((global_settings.sort_case & 1) << 2) | 260 ((global_settings.sort_case & 1) << 2) |
261 ((global_settings.discharge & 1) << 3) | 261 ((global_settings.discharge & 1) << 3) |
262 ((global_settings.statusbar & 1) << 4)); 262 ((global_settings.statusbar & 1) << 4) |
263 ((global_settings.show_hidden_files & 1) << 5));
263 264
264 config_block[0xf] = (unsigned char) 265 config_block[0xf] = (unsigned char)
265 ((global_settings.scroll_speed << 3) | 266 ((global_settings.scroll_speed << 3) |
@@ -345,6 +346,7 @@ void settings_load(void)
345 global_settings.sort_case = (config_block[0xe] >> 2) & 1; 346 global_settings.sort_case = (config_block[0xe] >> 2) & 1;
346 global_settings.discharge = (config_block[0xe] >> 3) & 1; 347 global_settings.discharge = (config_block[0xe] >> 3) & 1;
347 global_settings.statusbar = (config_block[0xe] >> 4) & 1; 348 global_settings.statusbar = (config_block[0xe] >> 4) & 1;
349 global_settings.show_hidden_files = (config_block[0xe] >> 5) & 1;
348 } 350 }
349 351
350 c = config_block[0xf] >> 3; 352 c = config_block[0xf] >> 3;
@@ -410,6 +412,7 @@ void settings_reset(void) {
410 global_settings.discharge = 0; 412 global_settings.discharge = 0;
411 global_settings.total_uptime = 0; 413 global_settings.total_uptime = 0;
412 global_settings.scroll_speed = 8; 414 global_settings.scroll_speed = 8;
415 global_settings.show_hidden_files = false;
413 global_settings.ff_rewind = DEFAULT_FF_REWIND_SETTING; 416 global_settings.ff_rewind = DEFAULT_FF_REWIND_SETTING;
414 global_settings.resume_index = -1; 417 global_settings.resume_index = -1;
415 global_settings.resume_offset = -1; 418 global_settings.resume_offset = -1;
diff --git a/apps/settings.h b/apps/settings.h
index 16ab41f8d5..36cf4930e1 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -69,6 +69,10 @@ struct user_settings
69 69
70 /* show status bar */ 70 /* show status bar */
71 bool statusbar; /* 0=hide, 1=show */ 71 bool statusbar; /* 0=hide, 1=show */
72
73 /* Hidden and dotfile settings */
74 bool show_hidden_files; /* 1=show dotfiles/hidden,
75 0=hide dotfiles/hidden */
72 76
73 /* geeky persistent statistics */ 77 /* geeky persistent statistics */
74 unsigned int total_uptime; /* total uptime since rockbox was first booted */ 78 unsigned int total_uptime; /* total uptime since rockbox was first booted */
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index 21b61d7093..b530073ceb 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -32,9 +32,14 @@
32#include "settings_menu.h" 32#include "settings_menu.h"
33#include "backlight.h" 33#include "backlight.h"
34#include "playlist.h" /* for playlist_shuffle */ 34#include "playlist.h" /* for playlist_shuffle */
35#include "fat.h" /* For dotfile settings */
35#include "powermgmt.h" 36#include "powermgmt.h"
36#include "rtc.h" 37#include "rtc.h"
37 38
39static void show_hidden_files(void)
40{
41 set_bool( "[Show hidden files]", &global_settings.show_hidden_files );
42}
38 43
39static void contrast(void) 44static void contrast(void)
40{ 45{
@@ -169,6 +174,7 @@ void settings_menu(void)
169#ifdef HAVE_RTC 174#ifdef HAVE_RTC
170 { "Time/Date", timedate_set }, 175 { "Time/Date", timedate_set },
171#endif 176#endif
177 { "Show hidden files", show_hidden_files },
172 { "FF/Rewind", ff_rewind }, 178 { "FF/Rewind", ff_rewind },
173 { "Resume", resume }, 179 { "Resume", resume },
174 }; 180 };
diff --git a/apps/tree.c b/apps/tree.c
index 7f0bf4362b..0e4a1962bc 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -190,15 +190,27 @@ static int showdir(char *path, int start)
190 if (!entry) 190 if (!entry)
191 break; 191 break;
192 192
193 len = strlen(entry->d_name);
194
193 /* skip directories . and .. */ 195 /* skip directories . and .. */
194 if ((entry->attribute & ATTR_DIRECTORY) && 196 if ((entry->attribute & ATTR_DIRECTORY) &&
195 (!strncmp(entry->d_name, ".", 1) || 197 (((len == 1) &&
196 !strncmp(entry->d_name, "..", 2))) { 198 (!strncmp(entry->d_name, ".", 1))) ||
199 ((len == 2) &&
200 (!strncmp(entry->d_name, "..", 2))))) {
201 i--;
202 continue;
203 }
204
205 /* Skip dotfiles if set to skip them */
206 if (!global_settings.show_hidden_files &&
207 ((entry->d_name[0]=='.') ||
208 (entry->attribute & ATTR_HIDDEN))) {
197 i--; 209 i--;
198 continue; 210 continue;
199 } 211 }
212
200 dptr->attr = entry->attribute; 213 dptr->attr = entry->attribute;
201 len = strlen(entry->d_name);
202 214
203 /* mark mp3 and m3u files as such */ 215 /* mark mp3 and m3u files as such */
204 if ( !(dptr->attr & ATTR_DIRECTORY) && (len > 4) ) { 216 if ( !(dptr->attr & ATTR_DIRECTORY) && (len > 4) ) {
@@ -209,10 +221,10 @@ static int showdir(char *path, int start)
209 dptr->attr |= TREE_ATTR_M3U; 221 dptr->attr |= TREE_ATTR_M3U;
210 } 222 }
211 223
212 /* filter hidden files and directories and non-mp3 or m3u files */ 224 /* filter non-mp3 or m3u files */
213 if ( global_settings.mp3filter && 225 if ( global_settings.mp3filter &&
214 ((dptr->attr & ATTR_HIDDEN) || 226 (!(dptr->attr &
215 !(dptr->attr & (ATTR_DIRECTORY|TREE_ATTR_MP3|TREE_ATTR_M3U))) ) { 227 (ATTR_DIRECTORY|TREE_ATTR_MP3|TREE_ATTR_M3U))) ) {
216 i--; 228 i--;
217 continue; 229 continue;
218 } 230 }
@@ -627,13 +639,23 @@ bool dirbrowse(char *root)
627 case TREE_MENU: { 639 case TREE_MENU: {
628 bool lastfilter = global_settings.mp3filter; 640 bool lastfilter = global_settings.mp3filter;
629 bool lastsortcase = global_settings.sort_case; 641 bool lastsortcase = global_settings.sort_case;
642 bool show_hidden_files = global_settings.show_hidden_files;
643
644#ifdef HAVE_LCD_BITMAP
645 bool laststate=statusbar(false);
646#endif
647
630 lcd_stop_scroll(); 648 lcd_stop_scroll();
631 main_menu(); 649 main_menu();
632 /* do we need to rescan dir? */ 650 /* do we need to rescan dir? */
633 if ( lastfilter != global_settings.mp3filter || 651 if ( lastfilter != global_settings.mp3filter ||
634 lastsortcase != global_settings.sort_case) 652 lastsortcase != global_settings.sort_case ||
653 show_hidden_files != global_settings.show_hidden_files)
635 lastdir[0] = 0; 654 lastdir[0] = 0;
636 restore = true; 655 restore = true;
656#ifdef HAVE_LCD_BITMAP
657 statusbar(laststate);
658#endif
637 break; 659 break;
638 } 660 }
639 661