-
Notifications
You must be signed in to change notification settings - Fork 1
/
winimg.cpp
122 lines (111 loc) · 2.63 KB
/
winimg.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// winimg.cpp : Defines the entry point for the console application.
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
//this driver file is still in development, and will
//change as the program takes modifications,
//it will also determine syntax for command line parameters
//see appropriate documentation
unsigned char Flags = 0;
char *sDrive = ""; //Source Drive
char *dDrive = ""; //Destination Drive
image obj;
bool create = false;
bool restore = false;
//This is for debugging purposes.
/*printf ("ARGC: %d\n",argc);
for (int j = 0; j < argc; j++)
{
printf("[%2d]: \"%s\"\n",j,argv[j]);
}*/
for (int i = 1; i < argc; i++)
{
if (argv[i][0] == '-')
{
switch (argv[i][1])
{
case 'c': // We're creating an image
Flags |= 1;
printf("Creating a file\n");
create=true;
break;
case 'r': // We're restoring an image
Flags |= 1;
printf("Restoring a file\n");
restore= true;
break;
//case 'z': // We're also compressing/decompressing the image
// printf("Compressing/Decompressing the file\n");
// break;
case 's': // the "source" is next
Flags |= 2;
printf("Source: ");
if (argc > (i+1) && argv[i+1][0] != '-')
{
// argv[i+1] is our source location
printf("\"%s\"\n",argv[i+1]);
sDrive = argv[i+1];
++i;
}
else
{
// Use a default source
printf("default\n");
}
break;
case 'd': // the "destination" is next
Flags |= 4;
printf("Destination: ");
if (argc > (i+1) && argv[i+1][0] != '-')
{
//argv[i+1] is our destination location
printf("\"%s\"\n",argv[i+1]);
dDrive=argv[i+1];
++i;
}
else
{
// Use a default destination
printf("default\n");
}
break;
default:
printf("\"%s\" is an unknown command\n",argv[i]);
}
}
else
{
printf("\"%s\" is an unknown command, should it be \"-%s\"?",argv[i],argv[i]);
}
}
if (Flags == 7)
{
printf("\n\n Everything is A-OK!!\n\n");
}
else
{
printf("Please specify:\n \"-c\" Create or \"-r\" Restore\n \"-s\" Source\n \"-d\" Destination");
return 1;
}
if (create)
{
FILE* imgfile = fopen("f:\\image.img","w+");
fprintf(imgfile,"");
fclose(imgfile);
cout << obj.setCSourceDrive(*sDrive);
cout << obj.setCDestinationDrive(*dDrive);
obj.setSectorSize(512);
obj.createImage();
}
if (restore)
{
FILE* imgfile = fopen("e:\\","w+");
//fprintf(imgfile,"");
fclose(imgfile);
cout << obj.setRSourceDrive(*sDrive);
cout << obj.setRDestinationDrive(*dDrive);
obj.setSectorSize(512);
obj.restoreImage();
}
return 0;
}