--- xmlTools/trunk/posUpdate/XmlPatch.cs 2013/03/26 02:30:48 742 +++ xmlTools/trunk/posUpdate/XmlPatch.cs 2013/05/10 14:42:11 868 @@ -95,7 +95,7 @@ namespace xmlTools //---------------------------------------------------Parse Operation command (start) try { - if (forceFiles == null) + if (String.IsNullOrEmpty(forceFiles)) { File = getPatchParameter(operation, "File"); } @@ -114,14 +114,14 @@ namespace xmlTools return false; } - if (Element == "") + if (String.IsNullOrEmpty(Element)) { return false; } //---------------------------------------------------Parse Operation command (end) List filesToProcess = new List(); - if (File == "") + if (String.IsNullOrEmpty(File)) { filesToProcess = Util.getAllXmlFiles(); //no file specified, use all xml files found in same folder } @@ -187,7 +187,7 @@ namespace xmlTools //---------------------------------------------------Parse Operation command (start) try { - if (forceFiles == null) + if (String.IsNullOrEmpty(forceFiles)) { File = getPatchParameter(operation, "File"); } @@ -206,7 +206,7 @@ namespace xmlTools return false; } - if (Element == "") + if (String.IsNullOrEmpty(Element)) { return false; } @@ -214,7 +214,7 @@ namespace xmlTools //---------------------------------------------------Parse Operation command (end) List filesToProcess = new List(); - if (File == "") + if (String.IsNullOrEmpty(File)) { filesToProcess = Util.getAllXmlFiles(); //no file specified, use all xml files found in same folder } @@ -271,7 +271,7 @@ namespace xmlTools command = command.Replace("@COMMAND ", ""); //get only the command to process - if (command.Trim() == "") + if (String.IsNullOrEmpty(command.Trim())) { Program.printAppError(Program.appErrors.PATCH_COMMAND_NOT_FOUND, "Error parsing commandOperation in Patch file: Command is empty."); return false; @@ -279,32 +279,35 @@ namespace xmlTools try { - if (forceFiles != null) + if (!String.IsNullOrEmpty(forceFiles)) { string paramType = ""; // Filename already exists? - if (command.IndexOf("filename:") != -1) + if (Util.ContainsIgnoreCase(command,"filename:")) { paramType = "filename:"; } - else if (command.IndexOf("filename=") != -1) + else if (Util.ContainsIgnoreCase(command, "filename=")) { paramType = "filename="; } // Add the filename if it doesn't exists else { - command = command.Insert(command.Length-1," -filename:" + this.forceFiles); // -1 to be inside quotes + command = command.Insert(command.Length," -filename:" + this.forceFiles); } - if (paramType != "") + if (!String.IsNullOrEmpty(paramType)) { int startIdx = command.IndexOf(paramType) + paramType.Length; int endIdx = command.IndexOf(" ", startIdx); // it may end with space if (endIdx == -1) { - endIdx = command.IndexOf("\"", startIdx); // or with quotes + endIdx = command.IndexOf("\n", startIdx); // or with endline + if(endIdx==-1){ // Filename parameters is the last one in the file (file ends with this parameter) + endIdx=command.Length-1; + } } string currFilename = command.Substring(startIdx, endIdx - startIdx); command = command.Replace(currFilename, this.forceFiles); @@ -314,12 +317,10 @@ namespace xmlTools if (this.globalNoBackups && !Util.ContainsIgnoreCase(command,"nobackups")) // add noBackup flag if provided as global parameter { - command = command.Insert(command.Length - 1, " -nobackups"); // -1 to be inside quotes + command = command.Insert(command.Length, " -nobackups"); } - command = command.Replace("\"", ""); // remove quotes - - Program.Main(command.Split(' ')); // use the current process is more efficient than start a new one + Program.Main(Util.stringToArgsArray(command)); // use the current process is more efficient than start a new one } catch (Exception e) {