-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogArgs.h
81 lines (62 loc) · 1.57 KB
/
progArgs.h
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
#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "common.h"
struct progArguments
{
char *file1;
char *file2;
char *file3;
bool flagCreate;
bool flagApply;
bool flagForce;
bool flagDiskIO;
bool flagQuiet;
bool flagVerbose;
bool flagShowStats;
bool flagIgnoreTimestamps;
bool flagMaximizeCompression; // double number of refs.
progArguments ()
{
file1 = file2 = file3 = nullptr;
flagCreate = false;
flagApply = false;
flagForce = false;
flagDiskIO = false;
flagQuiet = false;
flagVerbose = false;
flagShowStats = false;
flagIgnoreTimestamps = false;
flagMaximizeCompression = false;
}
~progArguments ()
{
free (file1);
free (file2);
free (file3);
}
int CreatePatchFileName ()
{
int i = 0;
char szNewName [PATH_MAX] = { 0 };
if (strlen(file2) > PATH_MAX - 1)
{
return -1;
}
strcpy (szNewName, file2);
for (i = (int)strlen(file2) - 1; file2[i] != '.' && i > 0; i--);
if (i == 0) // name may no point and extention
i = (int)strlen(file2);
if (i > PATH_MAX - 5)
{
fprintf (stderr, "File name is too long\n");
return -1;
}
strcpy (szNewName + i, ".foc");
printf ("Patch file set to %s\n", szNewName);
this->file3 = strdup (szNewName);
return 0;
}
int parseArguments (int argc, char *argv[]);
};