Changeset 37991
- Timestamp:
- 07/21/10 00:17:26 (3 years ago)
- Location:
- lang/c/AutoUpdater/trunk/recipes
- Files:
-
- 1 added
- 3 modified
-
Copy.c (modified) (6 diffs)
-
Copy.vcproj (modified) (1 diff)
-
extracter/7za/7za.h (modified) (1 diff)
-
icon.txt (added)
Legend:
- Unmodified
- Added
- Removed
-
lang/c/AutoUpdater/trunk/recipes/Copy.c
r37983 r37991 16 16 } 17 17 18 HANDLE LogFile = INVALID_HANDLE_VALUE; 19 18 20 int AUI_Debug(const TCHAR* format, ...) { 19 21 TCHAR output[1024]; /* http://msdn.microsoft.com/en-us/library/ms647550%28VS.85%29.aspx */ … … 23 25 va_end(ap); 24 26 OutputDebugString(output); 25 { 26 HANDLE hStdOut = INVALID_HANDLE_VALUE; 27 if (LogFile != INVALID_HANDLE_VALUE) { 27 28 DWORD written = 0; 28 char* mb = 0; 29 size_t mb_bytes = 0; 30 mb_bytes = (size_t)WideCharToMultiByte(CP_ACP, 0, output, -1, NULL, 0, NULL, NULL); 31 if (!mb_bytes) { 32 return -1; 33 } 34 mb = (char*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mb_bytes); 35 if (!WideCharToMultiByte(CP_ACP, 0, output, -1, mb, (int)mb_bytes, NULL, NULL)) { 36 return -1; 37 } 38 /* hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); */ 39 hStdOut = CreateFile(_T("c:\\temp\\up.txt"), GENERIC_WRITE, 40 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); 41 if (hStdOut == INVALID_HANDLE_VALUE) { 42 return -1; 43 } 44 SetFilePointer(hStdOut, 0, 0, FILE_END); 45 WriteFile(hStdOut, mb, mb_bytes, &written, NULL); 46 CloseHandle(hStdOut); 29 WriteFile(LogFile, output, lstrlen(output) * sizeof(output[0]), &written, NULL); 30 FlushFileBuffers(LogFile); 47 31 } 48 32 return 0; … … 143 127 TCHAR* clean_command = NULL; 144 128 TCHAR* temp_path = NULL; 129 TCHAR* log_full_path = NULL; 130 PVOID log_name = NULL; 145 131 TCHAR* command = NULL; 146 132 147 AUI_Debug(_T("***** UpdaterProcess start: pid=0x%x *****\n"), GetCurrentProcessId());148 133 { 149 134 size_t temp_path_chars = GetTempPath(0, NULL); … … 156 141 } 157 142 143 { 144 unsigned int pid = 0; 145 pid = GetCurrentProcessId(); 146 if (FormatMessage( 147 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY, 148 _T("AutoUpdaterLog.%1!x!.txt"), 149 0, 150 0, 151 (TCHAR*)&log_name, 152 0, 153 (va_list*)&pid)) { 154 log_full_path = AUI_PathAppend(temp_path, (TCHAR*)log_name); 155 if (log_full_path) { 156 LogFile = CreateFile(log_full_path, GENERIC_WRITE, 157 FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); 158 } 159 } 160 } 161 162 AUI_Debug(_T("***** UpdaterProcess start: pid=0x%x *****\n"), GetCurrentProcessId()); 163 164 158 165 hFile = CreateFile(_T("AutoUpdater.txt"), GENERIC_READ, 0, NULL, 159 166 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); 160 167 161 168 if (hFile == INVALID_HANDLE_VALUE) { 169 AUI_Debug(_T("config file not found\n")); 162 170 goto clean_up; 163 171 } … … 292 300 } 293 301 302 if (log_name) { 303 LocalFree(log_name); 304 } 305 294 306 if (clean_command) { 295 307 STARTUPINFO si; … … 306 318 } 307 319 320 if (LogFile != INVALID_HANDLE_VALUE) { 321 CloseHandle(LogFile); 322 if (complete) { 323 //DeleteFile(log_full_path); 324 } 325 } 308 326 309 327 /* 328 329 if (log_full_path) { 330 HeapFree(GetProcessHeap(), 0, log_full_path); 331 } 332 310 333 if (data) { 311 334 HeapFree(GetProcessHeap(), 0, data); -
lang/c/AutoUpdater/trunk/recipes/Copy.vcproj
r37987 r37991 207 207 > 208 208 <File 209 RelativePath=".\Copy.ico"210 >211 </File>212 <File213 209 RelativePath=".\Copy.rc" 214 210 > -
lang/c/AutoUpdater/trunk/recipes/extracter/7za/7za.h
r37982 r37991 16 16 17 17 { 18 DWORD exit_code = 0; 18 19 STARTUPINFO si; 19 20 PROCESS_INFORMATION pi; 20 TCHAR command[] = _T("extracter.exe x -y -oextracted archive_file");21 TCHAR command[] = _T("extracter.exe x -y -oextracted ArchiveFile"); 21 22 memset(&si, 0, sizeof(si)); 22 23 si.cb = sizeof(si); 23 24 memset(&pi, 0, sizeof(pi)); 24 CreateProcess(context->extracter_file_path, command, NULL, NULL, FALSE, 0, NULL, context->temp_dir_path, &si, &pi); 25 WaitForSingleObject(pi.hProcess, INFINITE); 25 if (CreateProcess(context->extracter_file_path, command, 26 NULL, NULL, FALSE, 0, NULL, 27 context->temp_dir_path, &si, &pi)) { 28 29 WaitForSingleObject(pi.hProcess, INFINITE); 30 if (GetExitCodeProcess(pi.hProcess, &exit_code)) { 31 if (exit_code == EXIT_SUCCESS) { 32 r = AUI_SUCCESS; 33 } 34 } 35 } 26 36 CloseHandle(pi.hThread); 27 37 CloseHandle(pi.hProcess); 28 38 } 29 return AUI_SUCCESS;39 return r; 30 40 } 31 41
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)