-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmdline.cpp
167 lines (138 loc) · 3.75 KB
/
cmdline.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
// cmdline.cpp
#include "stdafx.h"
std::string string_printf( const std::string format, ...)
{
char s[1024];
va_list vl;
va_start(vl, format);
vsnprintf(s, 1024, format.c_str(), vl);
va_end(vl);
return s;
}
CCmdLineParameter gName;
void CCmdLineParameter::Help()
{
puts
(
"grlog [-h] logfile\n"
" -h print this help text\n"
);
}
// s -> logPath, logName, logType
void CCmdLineParameter::SplitName(const std::string &s)
{
std::string s2;
size_t p = s.find_last_of("/\\");
if (p != std::string::npos)
{
logPath = s.substr(0, p+1);
s2 = s.substr(p+1);
}
else
{
logPath = "";
s2 = s;
}
p = s2.find_last_of(".");
if ((p != std::string::npos) && (p != 0))
{
logName = s2.substr(0, p);
logType = s2.substr(p);
}
else
{
logName = s2;
logType = "";
}
}
bool CCmdLineParameter::Process(int argc, char* argv[])
{
if (argc < 2) { puts("too few arguments!\n"); Help(); return false; }
dataStructure = 0;
logFileName = "";
for (int i = 1; i<argc; i++)
{
if (argv[i][0] == '-')
{
switch (argv[i][1])
{
case 'h': Help(); return false;
case 'p': dataStructure = 1; break;
default: puts("illegal argument!\n"); Help(); return false;
}
}
else
{
logFileName = argv[i];
}
}
if (logFileName.length() == 0) { Help(); return false; }
SplitName(logFileName);
if (logName.length() == 0) { Help(); return false; }
GenerateNames();
return true;
}
void CCmdLineParameter::GenerateNames()
{
switch (dataStructure)
{
case 1: GenNamesPSI(); break; // PSI report directory/naming structure structure
default: GenNames(); // rename and create method for default report directory structure
}
}
void CCmdLineParameter::GenNames()
{
// --- Data structure (PSI version)
std::string path = logPath + "report\\";
_mkdir(path.c_str());
std::string path1 = logPath;
if (path1.size()!=0) path1.erase(path1.end()-1,path1.end()); //to get folder name only
path_Report = path;
path_ClassList = path;
path_FailList = path;
path_Statistics = path;
path_Pick = path;
path_JSON = path + "database\\";
path_XML = path;
path_WaferMap = path + "maps\\";
path_YieldsFile = path;
path_ChipView = path + "chips\\";
name_Batch = path1;
name_Report = path_Report + logName + "_report.txt";
name_ClassList = path_ClassList + logName + "_classlist.txt";
name_FailList = path_FailList + logName + "_FailList.txt";
name_Statistics = path_Statistics + logName + "_stat.txt";
name_Pick = path_Pick + logName + "_pick.txt";
name_JSON = path_JSON + logName + "_db.json";
name_WaferMap = path_WaferMap + logName + "_wmap_";
name_YieldsFile = path_YieldsFile + "Stats_";
name_ChipView = path_ChipView + logName;
}
void CCmdLineParameter::GenNamesPSI()
{
// --- Data structure (PSI version)
std::string path = logPath + "report\\";
_mkdir(path.c_str());
std::string path1 = logPath;
if (path1.size()!=0) path1.erase(path1.end()-1,path1.end()); //to get folder name only
path_Report = path;
path_ClassList = path;
path_FailList = path;
path_Statistics = path;
path_Pick = path;
path_JSON = path + "database\\";
path_XML = path;
path_WaferMap = path + "maps\\";
path_YieldsFile = path;
path_ChipView = path + "chips\\";
name_Batch = path1;
name_Report = path_Report + logName + "_report.txt";
name_ClassList = path_ClassList + logName + "_classlist.txt";
name_FailList = path_FailList + logName + "_FailList.txt";
name_Statistics = path_Statistics + logName + "_stat.txt";
name_Pick = path_Pick + logName + "_pick.txt";
name_JSON = path_JSON + logName + "_db.json";
name_WaferMap = path_WaferMap + logName + "_wmap_";
name_YieldsFile = path_YieldsFile + "Stats_";
name_ChipView = path_ChipView + logName + "_ROC";
}