Read file and run the script.
114{
115 std::string Line;
117 bool Reset = false;
118 string CommandToExecute = "";
119 string PathOfScriptFile = "";
120
121
122
123
124
125 PathOfScriptFile = PathAndArgs.at(0);
127
128 ifstream File(PathOfScriptFile);
129
130 if (File.is_open())
131 {
133
134
135
136
138
139
140
141
142 Reset = true;
143
144 while (std::getline(File, Line))
145 {
146
147
148
150 {
151
152
153
154 if (Reset)
155 {
156 CommandToExecute.clear();
157 }
158
159
160
161
162 Reset = false;
163
164
165
166
167 CommandToExecute += Line + "\n";
168
169 continue;
170 }
171 else
172 {
173
174
175
176 Reset = true;
177
178
179
180
181 CommandToExecute += Line;
182 }
183
184
185
186
188
189
190
191
192 CommandToExecute.clear();
193 }
194
195
196
197
198 if (!CommandToExecute.empty())
199 {
201
202
203
204
205 CommandToExecute.clear();
206 }
207
208
209
210
212
213 File.close();
214 }
215
216 if (!IsOpened)
217 {
218 ShowMessages(
"err, invalid file specified for the script\n");
219 }
220}
UCHAR BOOLEAN
Definition BasicTypes.h:39
#define TRUE
Definition BasicTypes.h:55
#define FALSE
Definition BasicTypes.h:54
BOOLEAN CheckMultilineCommand(CHAR *CurrentCommand, BOOLEAN Reset)
check for multi-line commands
Definition interpreter.cpp:611
VOID CommandScriptRunCommand(std::string Input, vector< string > PathAndArgs)
Run the command.
Definition script.cpp:48
BOOLEAN g_ExecutingScript
Shows whether the target is executing a script form '.script' command or executing script by an argum...
Definition globals.h:492