| 828 |
theseven |
1 |
//
|
|
|
2 |
//
|
|
|
3 |
// Copyright 2011 TheSeven
|
|
|
4 |
//
|
|
|
5 |
//
|
|
|
6 |
// This file is part of emCORE.
|
|
|
7 |
//
|
|
|
8 |
// emCORE is free software: you can redistribute it and/or
|
|
|
9 |
// modify it under the terms of the GNU General Public License as
|
|
|
10 |
// published by the Free Software Foundation, either version 2 of the
|
|
|
11 |
// License, or (at your option) any later version.
|
|
|
12 |
//
|
|
|
13 |
// emCORE is distributed in the hope that it will be useful,
|
|
|
14 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
15 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
16 |
// See the GNU General Public License for more details.
|
|
|
17 |
//
|
|
|
18 |
// You should have received a copy of the GNU General Public License along
|
|
|
19 |
// with emCORE. If not, see <http://www.gnu.org/licenses/>.
|
|
|
20 |
//
|
|
|
21 |
//
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
#include "emcoreapp.h"
|
|
|
25 |
#include "libmkfat32.h"
|
|
|
26 |
#include "tools.h"
|
|
|
27 |
#include "util.h"
|
|
|
28 |
#include "main.h"
|
| 838 |
theseven |
29 |
#include "confirmchooser.h"
|
| 828 |
theseven |
30 |
|
|
|
31 |
|
| 838 |
theseven |
32 |
void run_clearcfg()
|
| 828 |
theseven |
33 |
{
|
| 838 |
theseven |
34 |
if (!run_confirmchooser("Clear Rockbox config?")) return;
|
| 828 |
theseven |
35 |
remove("/.rockbox/config.cfg");
|
|
|
36 |
memcpy(framebuf, bg, 176 * 132 * 3);
|
|
|
37 |
message(25, "Rockbox configuration", " has been cleared. ");
|
|
|
38 |
}
|
|
|
39 |
|
| 838 |
theseven |
40 |
void run_cleardb()
|
| 828 |
theseven |
41 |
{
|
| 838 |
theseven |
42 |
if (!run_confirmchooser("Clear Rockbox database?")) return;
|
| 828 |
theseven |
43 |
remove("/.rockbox/database_0.tcd");
|
|
|
44 |
remove("/.rockbox/database_1.tcd");
|
|
|
45 |
remove("/.rockbox/database_2.tcd");
|
|
|
46 |
remove("/.rockbox/database_3.tcd");
|
|
|
47 |
remove("/.rockbox/database_4.tcd");
|
|
|
48 |
remove("/.rockbox/database_5.tcd");
|
|
|
49 |
remove("/.rockbox/database_6.tcd");
|
|
|
50 |
remove("/.rockbox/database_7.tcd");
|
|
|
51 |
remove("/.rockbox/database_8.tcd");
|
|
|
52 |
remove("/.rockbox/database_9.tcd");
|
|
|
53 |
remove("/.rockbox/database_idx.tcd");
|
|
|
54 |
remove("/.rockbox/database_tmp.tcd");
|
|
|
55 |
remove("/.rockbox/database_state.tcd");
|
|
|
56 |
remove("/.rockbox/database_changelog.txt");
|
|
|
57 |
memcpy(framebuf, bg, 176 * 132 * 3);
|
|
|
58 |
message(37, "Rockbox database", "has been cleared.");
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
static void fat32_progressbar_init(void* user, int max)
|
|
|
62 |
{
|
|
|
63 |
progressbar_init((struct progressbar_state*)user,
|
|
|
64 |
10, 165, 74, 83, 0x77ff, 0xe8, 0x125f, 0, max);
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
static void fat32_progressbar_update(void* user, int current)
|
|
|
68 |
{
|
|
|
69 |
progressbar_setpos((struct progressbar_state*)user, current, false);
|
|
|
70 |
}
|
|
|
71 |
|
| 838 |
theseven |
72 |
void run_reformat()
|
| 828 |
theseven |
73 |
{
|
| 838 |
theseven |
74 |
if (!run_confirmchooser("Reformat data partition?")) return;
|
| 828 |
theseven |
75 |
memcpy(framebuf, bg, 176 * 132 * 3);
|
| 843 |
theseven |
76 |
rendertext(framebuf, 7, 65, 176, 0xff7fffff, 0, "Reformatting data partition");
|
| 828 |
theseven |
77 |
update_display(NULL);
|
|
|
78 |
displaylcd(0, 0, 176, 132, framebuf, 0, 0, 176);
|
|
|
79 |
struct emcorelib_header* libmkfat32 = loadlib(LIBMKFAT32_IDENTIFIER,
|
|
|
80 |
LIBMKFAT32_API_VERSION, "libmkf32");
|
|
|
81 |
struct libmkfat32_api* mf32 = (struct libmkfat32_api*)libmkfat32->api;
|
|
|
82 |
struct storage_info storageinfo;
|
|
|
83 |
storage_get_info(0, &storageinfo);
|
|
|
84 |
struct progressbar_state progressbar;
|
|
|
85 |
int rc = mf32->mkfat32(0, 0, storageinfo.num_sectors, 2048, 1, "iPod Nano2G",
|
|
|
86 |
&progressbar, fat32_progressbar_init, fat32_progressbar_update);
|
|
|
87 |
if (rc < 0) panicf(PANIC_KILLTHREAD, "Error formatting data partition: %08X", rc);
|
|
|
88 |
release_library(libmkfat32);
|
|
|
89 |
library_unload(libmkfat32);
|
|
|
90 |
memcpy(framebuf, bg, 176 * 132 * 3);
|
|
|
91 |
message(34, "Data partition has", "been reformatted.");
|
|
|
92 |
}
|