Changeset 37991

Show
Ignore:
Timestamp:
07/21/10 00:17:26 (3 years ago)
Author:
saturday06
Message:

icon copying

Location:
lang/c/AutoUpdater/trunk/recipes
Files:
1 added
3 modified

Legend:

Unmodified
Added
Removed
  • lang/c/AutoUpdater/trunk/recipes/Copy.c

    r37983 r37991  
    1616} 
    1717 
     18HANDLE LogFile = INVALID_HANDLE_VALUE; 
     19 
    1820int AUI_Debug(const TCHAR* format, ...) { 
    1921    TCHAR output[1024]; /* http://msdn.microsoft.com/en-us/library/ms647550%28VS.85%29.aspx */ 
     
    2325    va_end(ap); 
    2426    OutputDebugString(output); 
    25     { 
    26         HANDLE hStdOut = INVALID_HANDLE_VALUE; 
     27    if (LogFile != INVALID_HANDLE_VALUE) { 
    2728        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); 
    4731    } 
    4832    return 0; 
     
    143127    TCHAR* clean_command = NULL; 
    144128    TCHAR* temp_path = NULL; 
     129    TCHAR* log_full_path = NULL; 
     130    PVOID log_name = NULL; 
    145131    TCHAR* command = NULL; 
    146132 
    147     AUI_Debug(_T("***** UpdaterProcess start: pid=0x%x *****\n"), GetCurrentProcessId()); 
    148133    { 
    149134        size_t temp_path_chars = GetTempPath(0, NULL); 
     
    156141    } 
    157142 
     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 
    158165    hFile = CreateFile(_T("AutoUpdater.txt"), GENERIC_READ, 0, NULL,  
    159166        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); 
    160167 
    161168    if (hFile == INVALID_HANDLE_VALUE) { 
     169        AUI_Debug(_T("config file not found\n")); 
    162170        goto clean_up; 
    163171    } 
     
    292300        } 
    293301 
     302    if (log_name) { 
     303        LocalFree(log_name); 
     304    } 
     305 
    294306    if (clean_command) { 
    295307        STARTUPINFO si; 
     
    306318    } 
    307319 
     320    if (LogFile != INVALID_HANDLE_VALUE) { 
     321        CloseHandle(LogFile); 
     322        if (complete) { 
     323            //DeleteFile(log_full_path); 
     324        } 
     325    } 
    308326 
    309327    /* 
     328 
     329    if (log_full_path) { 
     330        HeapFree(GetProcessHeap(), 0, log_full_path); 
     331    } 
     332 
    310333    if (data) { 
    311334        HeapFree(GetProcessHeap(), 0, data); 
  • lang/c/AutoUpdater/trunk/recipes/Copy.vcproj

    r37987 r37991  
    207207                        > 
    208208                        <File 
    209                                 RelativePath=".\Copy.ico" 
    210                                 > 
    211                         </File> 
    212                         <File 
    213209                                RelativePath=".\Copy.rc" 
    214210                                > 
  • lang/c/AutoUpdater/trunk/recipes/extracter/7za/7za.h

    r37982 r37991  
    1616 
    1717    { 
     18        DWORD exit_code = 0; 
    1819        STARTUPINFO si; 
    1920        PROCESS_INFORMATION pi; 
    20         TCHAR command[] = _T("extracter.exe x -y -oextracted archive_file"); 
     21        TCHAR command[] = _T("extracter.exe x -y -oextracted ArchiveFile"); 
    2122        memset(&si, 0, sizeof(si)); 
    2223        si.cb = sizeof(si); 
    2324        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        } 
    2636                CloseHandle(pi.hThread); 
    2737                CloseHandle(pi.hProcess); 
    2838    } 
    29     return AUI_SUCCESS; 
     39    return r; 
    3040} 
    3141