ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/xmlTools/trunk/posUpdate/XmlPatch.cs
(Generate patch)

Comparing xmlTools/trunk/posUpdate/XmlPatch.cs (file contents):
Revision 742 by s10k, Tue Mar 26 02:30:48 2013 UTC vs.
Revision 868 by s10k, Fri May 10 14:42:11 2013 UTC

# Line 95 | Line 95 | namespace xmlTools
95              //---------------------------------------------------Parse Operation command (start)
96              try
97              {
98 <                if (forceFiles == null)
98 >                if (String.IsNullOrEmpty(forceFiles))
99                  {
100                      File = getPatchParameter(operation, "File");
101                  }
# Line 114 | Line 114 | namespace xmlTools
114                  return false;
115              }
116  
117 <            if (Element == "")
117 >            if (String.IsNullOrEmpty(Element))
118              {
119                  return false;
120              }
121  
122              //---------------------------------------------------Parse Operation command (end)
123              List<String> filesToProcess = new List<String>();
124 <            if (File == "")
124 >            if (String.IsNullOrEmpty(File))
125              {
126                  filesToProcess = Util.getAllXmlFiles(); //no file specified, use all xml files found in same folder
127              }
# Line 187 | Line 187 | namespace xmlTools
187              //---------------------------------------------------Parse Operation command (start)
188              try
189              {
190 <                if (forceFiles == null)
190 >                if (String.IsNullOrEmpty(forceFiles))
191                  {
192                      File = getPatchParameter(operation, "File");
193                  }
# Line 206 | Line 206 | namespace xmlTools
206                  return false;
207              }
208  
209 <            if (Element == "")
209 >            if (String.IsNullOrEmpty(Element))
210              {
211                  return false;
212              }
# Line 214 | Line 214 | namespace xmlTools
214              //---------------------------------------------------Parse Operation command (end)
215  
216              List<String> filesToProcess = new List<String>();
217 <            if (File == "")
217 >            if (String.IsNullOrEmpty(File))
218              {
219                  filesToProcess = Util.getAllXmlFiles(); //no file specified, use all xml files found in same folder
220              }
# Line 271 | Line 271 | namespace xmlTools
271  
272              command = command.Replace("@COMMAND ", ""); //get only the command to process
273  
274 <            if (command.Trim() == "")
274 >            if (String.IsNullOrEmpty(command.Trim()))
275              {
276                  Program.printAppError(Program.appErrors.PATCH_COMMAND_NOT_FOUND, "Error parsing commandOperation in Patch file: Command is empty.");
277                  return false;
# Line 279 | Line 279 | namespace xmlTools
279  
280              try
281              {
282 <                if (forceFiles != null)
282 >                if (!String.IsNullOrEmpty(forceFiles))
283                  {
284                      string paramType = "";
285  
286                      // Filename already exists?
287 <                    if (command.IndexOf("filename:") != -1)
287 >                    if (Util.ContainsIgnoreCase(command,"filename:"))
288                      {
289                          paramType = "filename:";
290                      }
291 <                    else if (command.IndexOf("filename=") != -1)
291 >                    else if (Util.ContainsIgnoreCase(command, "filename="))
292                      {
293                          paramType = "filename=";
294                      }
295                      // Add the filename if it doesn't exists
296                      else
297                      {
298 <                        command = command.Insert(command.Length-1," -filename:" + this.forceFiles); // -1 to be inside quotes
298 >                        command = command.Insert(command.Length," -filename:" + this.forceFiles);
299                      }
300  
301 <                    if (paramType != "")
301 >                    if (!String.IsNullOrEmpty(paramType))
302                      {
303                          int startIdx = command.IndexOf(paramType) + paramType.Length;
304                          int endIdx = command.IndexOf(" ", startIdx); // it may end with space
305                          if (endIdx == -1)
306                          {
307 <                            endIdx = command.IndexOf("\"", startIdx); // or with quotes
307 >                            endIdx = command.IndexOf("\n", startIdx); // or with endline
308 >                            if(endIdx==-1){ // Filename parameters is the last one in the file (file ends with this parameter)
309 >                                endIdx=command.Length-1;
310 >                            }
311                          }
312                          string currFilename = command.Substring(startIdx, endIdx - startIdx);
313                          command = command.Replace(currFilename, this.forceFiles);
# Line 314 | Line 317 | namespace xmlTools
317  
318                  if (this.globalNoBackups && !Util.ContainsIgnoreCase(command,"nobackups")) // add noBackup flag if provided as global parameter
319                  {
320 <                    command = command.Insert(command.Length - 1, " -nobackups"); // -1 to be inside quotes
320 >                    command = command.Insert(command.Length, " -nobackups");
321                  }
322  
323 <                command = command.Replace("\"", ""); // remove quotes
321 <
322 <                Program.Main(command.Split(' ')); // use the current process is more efficient than start a new one
323 >                Program.Main(Util.stringToArgsArray(command)); // use the current process is more efficient than start a new one
324              }
325              catch (Exception e)
326              {

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)