blob: 1d52ee2ee41d4ac4575d92571d0bd7961464f439 [file] [log] [blame]
srs56943860cbe2011-09-10 20:29:53 -04001/*
2 Copyright (C) 2011 <Roderick W. Smith>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18*/
19
20/* This class implements an interactive curses-based interface atop the
21 GPTData class */
22
23#include <string>
24#include "gptcurses.h"
25
26using namespace std;
27
28#define MAX_OPTIONS 50
29
30int main(int argc, char *argv[]) {
31 string device = "";
32
33 if (!SizesOK())
34 exit(1);
35
36 switch (argc) {
37 case 1:
38 cout << "Type device filename, or press <Enter> to exit: ";
39 device = ReadString();
40 if (device.length() == 0)
41 exit(0);
42 break;
43 case 2: // basic usage
44 device = argv[1];
45 break;
46 default:
47 cerr << "Usage: " << argv[0] << " device_file\n";
48 exit(1);
49 break;
50 } // switch
51
52 GPTDataCurses theGPT;
53
54 if (theGPT.LoadPartitions(device)) {
55 if (theGPT.GetState() != use_gpt) {
56 Report("Warning! Non-GPT or damaged disk detected! This program will attempt to\n"
57 "convert to GPT form or repair damage to GPT data structures, but may not\n"
58 "succeed. Use gdisk or another disk repair tool if you have a damaged GPT\n"
59 "disk.");
60 } // if
61 theGPT.MainMenu();
62 } else {
63 Report("Could not load partitions from '" + device + "'! Aborting!");
64 } // if/else
65} // main