forked from len0rd/rockbox
FS #8985 by Robert Menes. Add support for removing some Linux files/directories in disktidy.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17210 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
fd773cbda6
commit
5818bc3c31
1 changed files with 45 additions and 20 deletions
|
@ -35,7 +35,8 @@ enum tidy_system
|
||||||
{
|
{
|
||||||
TIDY_MAC = 0,
|
TIDY_MAC = 0,
|
||||||
TIDY_WIN = 1,
|
TIDY_WIN = 1,
|
||||||
TIDY_BOTH = 2,
|
TIDY_NIX = 2,
|
||||||
|
TIDY_ALL = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* variable button definitions */
|
/* variable button definitions */
|
||||||
|
@ -145,9 +146,9 @@ enum tidy_return tidy_removedir(const char *name, int *removed)
|
||||||
return TIDY_RETURN_ABORT;
|
return TIDY_RETURN_ABORT;
|
||||||
}
|
}
|
||||||
if (rb->default_event_handler(button) == SYS_USB_CONNECTED)
|
if (rb->default_event_handler(button) == SYS_USB_CONNECTED)
|
||||||
{
|
{
|
||||||
rb->closedir(dir);
|
rb->closedir(dir);
|
||||||
return TIDY_RETURN_USB;
|
return TIDY_RETURN_USB;
|
||||||
}
|
}
|
||||||
|
|
||||||
rb->yield();
|
rb->yield();
|
||||||
|
@ -213,9 +214,9 @@ enum tidy_return tidy_clean(const char *name, int *removed, \
|
||||||
return TIDY_RETURN_ABORT;
|
return TIDY_RETURN_ABORT;
|
||||||
}
|
}
|
||||||
if (rb->default_event_handler(button) == SYS_USB_CONNECTED)
|
if (rb->default_event_handler(button) == SYS_USB_CONNECTED)
|
||||||
{
|
{
|
||||||
rb->closedir(dir);
|
rb->closedir(dir);
|
||||||
return TIDY_RETURN_USB;
|
return TIDY_RETURN_USB;
|
||||||
}
|
}
|
||||||
|
|
||||||
rb->yield();
|
rb->yield();
|
||||||
|
@ -234,7 +235,7 @@ enum tidy_return tidy_clean(const char *name, int *removed, \
|
||||||
/* check if we are in root directory "/" */
|
/* check if we are in root directory "/" */
|
||||||
if (rb->strcmp(name, "/") == 0)
|
if (rb->strcmp(name, "/") == 0)
|
||||||
{
|
{
|
||||||
if ((system == TIDY_MAC) || (system == TIDY_BOTH))
|
if ((system == TIDY_MAC) || (system == TIDY_ALL))
|
||||||
{
|
{
|
||||||
/* mac directories */
|
/* mac directories */
|
||||||
if (rb->strcmp(entry->d_name, ".Trashes") == 0)
|
if (rb->strcmp(entry->d_name, ".Trashes") == 0)
|
||||||
|
@ -247,7 +248,7 @@ enum tidy_return tidy_clean(const char *name, int *removed, \
|
||||||
|
|
||||||
if (del == 0)
|
if (del == 0)
|
||||||
{
|
{
|
||||||
if ((system == TIDY_WIN) || (system == TIDY_BOTH))
|
if ((system == TIDY_WIN) || (system == TIDY_ALL))
|
||||||
{
|
{
|
||||||
/* windows directories */
|
/* windows directories */
|
||||||
if (rb->strcmp(entry->d_name, "Recycled") == 0 \
|
if (rb->strcmp(entry->d_name, "Recycled") == 0 \
|
||||||
|
@ -273,7 +274,7 @@ enum tidy_return tidy_clean(const char *name, int *removed, \
|
||||||
/* file */
|
/* file */
|
||||||
del = 0;
|
del = 0;
|
||||||
|
|
||||||
if ((system == TIDY_MAC) || (system == TIDY_BOTH))
|
if ((system == TIDY_MAC) || (system == TIDY_ALL))
|
||||||
{
|
{
|
||||||
/* remove mac files */
|
/* remove mac files */
|
||||||
if ((rb->strcmp(entry->d_name, ".DS_Store") == 0) || \
|
if ((rb->strcmp(entry->d_name, ".DS_Store") == 0) || \
|
||||||
|
@ -293,7 +294,7 @@ enum tidy_return tidy_clean(const char *name, int *removed, \
|
||||||
|
|
||||||
if (del == 0)
|
if (del == 0)
|
||||||
{
|
{
|
||||||
if ((system == TIDY_WIN) || (system == TIDY_BOTH))
|
if ((system == TIDY_WIN) || (system == TIDY_ALL))
|
||||||
{
|
{
|
||||||
/* remove windows files*/
|
/* remove windows files*/
|
||||||
if ((rb->strcmp(entry->d_name, "Thumbs.db") == 0))
|
if ((rb->strcmp(entry->d_name, "Thumbs.db") == 0))
|
||||||
|
@ -308,9 +309,29 @@ enum tidy_return tidy_clean(const char *name, int *removed, \
|
||||||
rb->remove(fullname);
|
rb->remove(fullname);
|
||||||
del = 1;
|
del = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (del == 0)
|
||||||
|
{
|
||||||
|
if ((system ==TIDY_NIX) || (system == TIDY_ALL))
|
||||||
|
{
|
||||||
|
/* remove linux files*/
|
||||||
|
if ((rb->strcmp(entry->d_name, ".dolphinview") == 0) || \
|
||||||
|
(rb->strncmp(entry->d_name, ".d3lphinview", 2) == 0))
|
||||||
|
{
|
||||||
|
*removed += 1; /* increment removed files counter */
|
||||||
|
|
||||||
|
/* get absolute path */
|
||||||
|
char fullname[MAX_PATH];
|
||||||
|
tidy_get_absolute_path(entry, fullname, name);
|
||||||
|
|
||||||
|
/* delete file */
|
||||||
|
rb->remove(fullname);
|
||||||
|
del = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rb->closedir(dir);
|
rb->closedir(dir);
|
||||||
return status;
|
return status;
|
||||||
|
@ -354,17 +375,18 @@ enum plugin_status tidy_do(enum tidy_system system)
|
||||||
|
|
||||||
int tidy_lcd_menu(void)
|
int tidy_lcd_menu(void)
|
||||||
{
|
{
|
||||||
int selection, ret = 2;
|
int selection, ret = 3;
|
||||||
bool menu_quit = false;
|
bool menu_quit = false;
|
||||||
|
|
||||||
MENUITEM_STRINGLIST(menu,"Disktidy Menu",NULL,"Start Cleaning",
|
MENUITEM_STRINGLIST(menu,"Disktidy Menu",NULL,"Start Cleaning",
|
||||||
"Files to Clean","Quit");
|
"Files to Clean","Quit");
|
||||||
|
|
||||||
static const struct opt_items system_option[3] =
|
static const struct opt_items system_option[] =
|
||||||
{
|
{
|
||||||
{ "Mac", -1 },
|
{ "Mac", -1 },
|
||||||
{ "Windows", -1 },
|
{ "Windows", -1 },
|
||||||
{ "Both", -1 }
|
{ "Linux", -1 },
|
||||||
|
{ "All", -1 }
|
||||||
};
|
};
|
||||||
|
|
||||||
while (!menu_quit)
|
while (!menu_quit)
|
||||||
|
@ -377,7 +399,7 @@ int tidy_lcd_menu(void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
rb->set_option("Files to Clean", &ret, INT, system_option, 3, NULL);
|
rb->set_option("Files to Clean", &ret, INT, system_option, 4, NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -392,7 +414,7 @@ int tidy_lcd_menu(void)
|
||||||
/* this is the plugin entry point */
|
/* this is the plugin entry point */
|
||||||
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||||
{
|
{
|
||||||
enum tidy_system system = TIDY_BOTH;
|
enum tidy_system system = TIDY_ALL;
|
||||||
enum tidy_return status;
|
enum tidy_return status;
|
||||||
|
|
||||||
(void)parameter;
|
(void)parameter;
|
||||||
|
@ -408,12 +430,15 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||||
system = TIDY_WIN;
|
system = TIDY_WIN;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
system = TIDY_BOTH;
|
system = TIDY_NIX;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
system = TIDY_ALL;
|
||||||
break;
|
break;
|
||||||
case 99:
|
case 99:
|
||||||
return PLUGIN_OK;
|
return PLUGIN_OK;
|
||||||
default:
|
default:
|
||||||
system = TIDY_BOTH;
|
system = TIDY_ALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue