Changeset 37964
- Timestamp:
- 07/19/10 17:15:51 (3 years ago)
- Location:
- lang/c/AutoUpdater/trunk
- Files:
-
- 3 modified
-
AutoUpdater.c (modified) (1 diff)
-
AutoUpdater.sln (modified) (1 diff)
-
UpdaterProcess.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/c/AutoUpdater/trunk/AutoUpdater.c
r37962 r37964 965 965 _T("%s\n") 966 966 _T("%s\n") 967 , GetCurrentProcessId(), context->extracted_dir_path, target, myname, cd); 967 _T("%s\n") 968 , GetCurrentProcessId(), context->extracted_dir_path, target, myname, cd, context->temp_dir_path); 968 969 fclose(f); 969 970 } 971 970 972 971 973 { -
lang/c/AutoUpdater/trunk/AutoUpdater.sln
r37926 r37964 1 1 2 2 Microsoft Visual Studio Solution File, Format Version 10.00 3 # Visual Studio20083 # Visual C++ Express 2008 4 4 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AutoUpdater", "AutoUpdater.vcproj", "{5BDD41D2-DE9F-41CD-B980-79A6EF0CFB67}" 5 5 EndProject -
lang/c/AutoUpdater/trunk/UpdaterProcess.c
r37963 r37964 117 117 DWORD bytes_got = 0; 118 118 TCHAR* data = NULL; 119 TCHAR* lines[5] = {NULL, NULL, NULL, NULL, NULL}; 119 TCHAR* new_program = NULL; 120 TCHAR* new_program_cd = NULL; 121 TCHAR* update_from = NULL; 122 TCHAR* update_to = NULL; 123 TCHAR* clean_after = NULL; 124 TCHAR* pid_string = NULL; 120 125 DWORD pid = 0; 121 126 int complete = 0; … … 152 157 } 153 158 154 { /* each lines to lines[5] */ 159 { 160 TCHAR* lines[6]; 155 161 size_t i = 0; 156 162 size_t data_count = (bytes / sizeof(data[0])); 157 163 unsigned line = 0; 164 memset(lines, 0, sizeof(lines)); 158 165 for (i = 0; i < data_count; ++i) { 159 166 if (data[i] == _T('\r')) { … … 171 178 } 172 179 } 173 } 174 175 AUI_Debug(_T("pid=%s, from=%s, to=%s\nnewproc=%s, cd=%s\n"), lines[0], lines[1], lines[2], lines[3], lines[4]); 180 pid_string = lines[0]; 181 update_from = lines[1]; 182 update_to = lines[2]; 183 new_program = lines[3]; 184 new_program_cd = lines[4]; 185 clean_after = lines[5]; 186 } 187 188 AUI_Debug(_T("pid=%s, from=%s, to=%s\nnewproc=%s, cd=%s clean=%s\n"), 189 pid_string, update_from, update_to, new_program, new_program_cd, clean_after); 176 190 177 { 178 TCHAR* pid_string; 191 if (pid_string) { 179 192 int i = 0; 180 pid_string = lines[0];181 193 for (i = 0; pid_string[i]; ++i) { 182 194 if (pid_string[i] < _T('0') || _T('9') < pid_string[i]) { … … 189 201 } 190 202 191 192 { 203 if (clean_after) { 193 204 TCHAR comspec[MAX_PATH]; 194 205 TCHAR rd_command[] = _T("\"%s\" /c rd /s /q \"%s\""); … … 198 209 } 199 210 200 clean_command_len = lstrlen(comspec) + lstrlen(rd_command) + lstrlen( lines[4]);211 clean_command_len = lstrlen(comspec) + lstrlen(rd_command) + lstrlen(clean_after); 201 212 clean_command = (TCHAR*)HeapAlloc(GetProcessHeap(), 202 213 HEAP_ZERO_MEMORY, clean_command_len * sizeof(TCHAR)); … … 204 215 goto clean_up; 205 216 } 206 wsprintf(clean_command, rd_command, comspec, lines[4]);217 wsprintf(clean_command, rd_command, comspec, clean_after); 207 218 } 208 219 … … 215 226 AUI_Debug(L"start copy\n"); 216 227 217 if (CopyDirectory( lines[1], lines[2])) {228 if (CopyDirectory(update_from, update_to)) { 218 229 complete = 1; 219 230 } 220 231 221 232 clean_up: 222 if ( lines[3] && lines[4]) {233 if (new_program && new_program_cd) { 223 234 TCHAR* arg = NULL; 224 235 TCHAR command_format[] = _T("\"%s\" %s"); … … 233 244 } 234 245 command_len = lstrlen(command_format); 235 command_len += lstrlen( lines[3]);246 command_len += lstrlen(new_program); 236 247 command_len += lstrlen(arg); 237 248 238 249 command = (TCHAR*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (unsigned)command_len * sizeof(TCHAR)); 239 250 if (command) { 240 wsprintf(command, command_format, lines[3], arg);241 } 242 } 243 244 if (command && lines[4]) {251 wsprintf(command, command_format, new_program, arg); 252 } 253 } 254 255 if (command && new_program_cd) { 245 256 STARTUPINFO si; 246 257 PROCESS_INFORMATION pi; … … 250 261 memset(&pi, 0, sizeof(pi)); 251 262 252 CreateProcess(NULL, command, NULL, NULL, FALSE, 0, NULL, lines[4], &si, &pi);263 CreateProcess(NULL, command, NULL, NULL, FALSE, 0, NULL, new_program_cd, &si, &pi); 253 264 e = GetLastError(); 254 AUI_Debug(_T("CreateProcess(): command=%s, cd=%s, error=%d\n"), command, lines[4], e);265 AUI_Debug(_T("CreateProcess(): command=%s, cd=%s, error=%d\n"), command, new_program_cd, e); 255 266 256 267 CloseHandle(pi.hThread); … … 269 280 si.wShowWindow = SW_HIDE; 270 281 memset(&pi, 0, sizeof(pi)); 282 AUI_Debug(_T("CreateProcess(del): command=%s, cd=%s\n"), clean_command, temp_path); 271 283 CreateProcess(NULL, clean_command, NULL, NULL, FALSE, 0, NULL, temp_path, &si, &pi); 272 284 /* … … 276 288 } 277 289 290 278 291 /* 279 292 if (data) {
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)