Changeset 977
- Timestamp:
- 05/05/09 13:08:20 (4 years ago)
- Location:
- branches/eraser6
- Files:
-
- 2 edited
-
Eraser/Program.cs (modified) (3 diffs)
-
ShellExt/CtxMenu.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/Eraser/Program.cs
r952 r977 696 696 while (commaPos != -1) 697 697 { 698 //Extract the current subparameter, and dissect the subparameter at 699 //the first =. 700 string subParam = param.Substring(lastPos, commaPos - lastPos); 701 int equalPos = subParam.IndexOf('='); 702 if (equalPos == -1) 703 result.Add(new KeyValuePair<string, string>(subParam, null)); 698 //Check that the first parameter is not a \ otherwise this comma 699 //is escaped 700 if (commaPos == 0 || //No possibility of escaping 701 (commaPos >= 1 && param[commaPos - 1] != '\\') || //Second character 702 (commaPos >= 2 && param[commaPos - 2] == '\\')) //Cannot be a \\ which is an escape 703 { 704 //Extract the current subparameter, and dissect the subparameter 705 //at the first =. 706 string subParam = param.Substring(lastPos, commaPos - lastPos); 707 int equalPos = -1; 708 709 do 710 { 711 equalPos = subParam.IndexOf('=', equalPos + 1); 712 if (equalPos == -1) 713 { 714 result.Add(new KeyValuePair<string, string>( 715 UnescapeCommandLine(subParam), null)); 716 } 717 else if (equalPos == 0 || //No possibility of escaping 718 (equalPos >= 1 && subParam[equalPos - 1] != '\\') ||//Second character 719 (equalPos >= 2 && subParam[equalPos - 2] == '\\')) //Double \\ which is an escape 720 { 721 result.Add(new KeyValuePair<string, string>( 722 UnescapeCommandLine(subParam.Substring(0, equalPos)), 723 UnescapeCommandLine(subParam.Substring(equalPos + 1)))); 724 break; 725 } 726 } 727 while (equalPos != -1); 728 lastPos = ++commaPos; 729 } 704 730 else 705 result.Add(new KeyValuePair<string, string>(subParam.Substring(0, equalPos), 706 subParam.Substring(equalPos + 1))); 731 ++commaPos; 707 732 708 733 //Find the next , 709 lastPos = ++commaPos;710 734 commaPos = param.IndexOf(',', commaPos); 711 735 } 712 736 713 737 return result; 738 } 739 740 /// <summary> 741 /// Unescapes a subparameter command line, removing the extra 742 /// </summary> 743 /// <param name="param"></param> 744 /// <returns></returns> 745 private static string UnescapeCommandLine(string param) 746 { 747 StringBuilder result = new StringBuilder(param.Length); 748 for (int i = 0; i < param.Length; ++i) 749 if (param[i] == '\\' && i < param.Length - 1) 750 result.Append(param[++i]); 751 else 752 result.Append(param[i]); 753 return result.ToString(); 714 754 } 715 755 … … 1105 1145 try 1106 1146 { 1107 using (Program.eraserClient = new RemoteExecutorClient()) 1108 { 1109 if (!((RemoteExecutorClient)Program.eraserClient).Connect()) 1147 using (RemoteExecutorClient client = new RemoteExecutorClient()) 1148 { 1149 client.Run(); 1150 if (!client.IsConnected) 1110 1151 { 1111 1152 //The client cannot connect to the server. This probably means … … 1115 1156 eraserInstance.WaitForInputIdle(); 1116 1157 1117 if (!((RemoteExecutorClient)Program.eraserClient).Connect()) 1158 client.Run(); 1159 if (!client.IsConnected) 1118 1160 throw new IOException("Eraser cannot connect to the running " + 1119 1161 "instance for erasures."); 1120 1162 } 1121 1163 1122 Program.eraserClient.Run(); 1123 Program.eraserClient.Tasks.Add(task); 1164 client.Tasks.Add(task); 1124 1165 } 1125 1166 } -
branches/eraser6/ShellExt/CtxMenu.cpp
r878 r977 533 533 DWORD attributes = GetFileAttributes(item.c_str()); 534 534 535 //Escape the command line (= and , are special characters) 536 std::wstring escapedItem; 537 escapedItem.reserve(item.length()); 538 for (std::wstring::const_iterator i = item.begin(); i != item.end(); ++i) 539 { 540 if (wcschr(L"\\=,", *i)) 541 escapedItem += '\\'; 542 escapedItem += *i; 543 } 544 535 545 //Add the correct command line for the file type. 536 546 if (attributes & FILE_ATTRIBUTE_DIRECTORY) 537 commandLine += L"\"-d=" + item + L"\" ";547 commandLine += L"\"-d=" + escapedItem + L"\" "; 538 548 else 539 commandLine += L"\"" + item + L"\" ";549 commandLine += L"\"" + escapedItem + L"\" "; 540 550 } 541 551 } … … 740 750 finalParameters = parametersStrm.str(); 741 751 } 752 MessageBox(NULL, finalParameters.c_str(), L"Eraser Command Line", MB_OK | MB_ICONINFORMATION); 742 753 743 754 //If the process must be elevated we use ShellExecute with the runas verb
Note: See TracChangeset
for help on using the changeset viewer.
