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)
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 )
((global_settings.mp3filter & 1) << 1) |
((global_settings.sort_case & 1) << 2) |
((global_settings.discharge & 1) << 3) |
- ((global_settings.statusbar & 1) << 4));
+ ((global_settings.statusbar & 1) << 4) |
+ ((global_settings.show_hidden_files & 1) << 5));
config_block[0xf] = (unsigned char)
((global_settings.scroll_speed << 3) |
@@ -345,6 +346,7 @@ void settings_load(void)
global_settings.sort_case = (config_block[0xe] >> 2) & 1;
global_settings.discharge = (config_block[0xe] >> 3) & 1;
global_settings.statusbar = (config_block[0xe] >> 4) & 1;
+ global_settings.show_hidden_files = (config_block[0xe] >> 5) & 1;
}
c = config_block[0xf] >> 3;
@@ -410,6 +412,7 @@ void settings_reset(void) {
global_settings.discharge = 0;
global_settings.total_uptime = 0;
global_settings.scroll_speed = 8;
+ global_settings.show_hidden_files = false;
global_settings.ff_rewind = DEFAULT_FF_REWIND_SETTING;
global_settings.resume_index = -1;
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
/* show status bar */
bool statusbar; /* 0=hide, 1=show */
+
+ /* Hidden and dotfile settings */
+ bool show_hidden_files; /* 1=show dotfiles/hidden,
+ 0=hide dotfiles/hidden */
/* geeky persistent statistics */
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 @@
#include "settings_menu.h"
#include "backlight.h"
#include "playlist.h" /* for playlist_shuffle */
+#include "fat.h" /* For dotfile settings */
#include "powermgmt.h"
#include "rtc.h"
+static void show_hidden_files(void)
+{
+ set_bool( "[Show hidden files]", &global_settings.show_hidden_files );
+}
static void contrast(void)
{
@@ -169,6 +174,7 @@ void settings_menu(void)
#ifdef HAVE_RTC
{ "Time/Date", timedate_set },
#endif
+ { "Show hidden files", show_hidden_files },
{ "FF/Rewind", ff_rewind },
{ "Resume", resume },
};
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)
if (!entry)
break;
+ len = strlen(entry->d_name);
+
/* skip directories . and .. */
if ((entry->attribute & ATTR_DIRECTORY) &&
- (!strncmp(entry->d_name, ".", 1) ||
- !strncmp(entry->d_name, "..", 2))) {
+ (((len == 1) &&
+ (!strncmp(entry->d_name, ".", 1))) ||
+ ((len == 2) &&
+ (!strncmp(entry->d_name, "..", 2))))) {
+ i--;
+ continue;
+ }
+
+ /* Skip dotfiles if set to skip them */
+ if (!global_settings.show_hidden_files &&
+ ((entry->d_name[0]=='.') ||
+ (entry->attribute & ATTR_HIDDEN))) {
i--;
continue;
}
+
dptr->attr = entry->attribute;
- len = strlen(entry->d_name);
/* mark mp3 and m3u files as such */
if ( !(dptr->attr & ATTR_DIRECTORY) && (len > 4) ) {
@@ -209,10 +221,10 @@ static int showdir(char *path, int start)
dptr->attr |= TREE_ATTR_M3U;
}
- /* filter hidden files and directories and non-mp3 or m3u files */
+ /* filter non-mp3 or m3u files */
if ( global_settings.mp3filter &&
- ((dptr->attr & ATTR_HIDDEN) ||
- !(dptr->attr & (ATTR_DIRECTORY|TREE_ATTR_MP3|TREE_ATTR_M3U))) ) {
+ (!(dptr->attr &
+ (ATTR_DIRECTORY|TREE_ATTR_MP3|TREE_ATTR_M3U))) ) {
i--;
continue;
}
@@ -627,13 +639,23 @@ bool dirbrowse(char *root)
case TREE_MENU: {
bool lastfilter = global_settings.mp3filter;
bool lastsortcase = global_settings.sort_case;
+ bool show_hidden_files = global_settings.show_hidden_files;
+
+#ifdef HAVE_LCD_BITMAP
+ bool laststate=statusbar(false);
+#endif
+
lcd_stop_scroll();
main_menu();
/* do we need to rescan dir? */
if ( lastfilter != global_settings.mp3filter ||
- lastsortcase != global_settings.sort_case)
+ lastsortcase != global_settings.sort_case ||
+ show_hidden_files != global_settings.show_hidden_files)
lastdir[0] = 0;
restore = true;
+#ifdef HAVE_LCD_BITMAP
+ statusbar(laststate);
+#endif
break;
}