Changeset 37964

Show
Ignore:
Timestamp:
07/19/10 17:15:51 (3 years ago)
Author:
saturday06
Message:

del...

Location:
lang/c/AutoUpdater/trunk
Files:
3 modified

Legend:

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

    r37962 r37964  
    965965            _T("%s\n") 
    966966            _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); 
    968969        fclose(f); 
    969970    } 
     971 
    970972 
    971973    { 
  • lang/c/AutoUpdater/trunk/AutoUpdater.sln

    r37926 r37964  
    11 
    22Microsoft Visual Studio Solution File, Format Version 10.00 
    3 # Visual Studio 2008 
     3# Visual C++ Express 2008 
    44Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AutoUpdater", "AutoUpdater.vcproj", "{5BDD41D2-DE9F-41CD-B980-79A6EF0CFB67}" 
    55EndProject 
  • lang/c/AutoUpdater/trunk/UpdaterProcess.c

    r37963 r37964  
    117117    DWORD bytes_got = 0; 
    118118    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; 
    120125    DWORD pid = 0; 
    121126    int complete = 0; 
     
    152157    } 
    153158 
    154     { /* each lines to lines[5] */ 
     159    { 
     160        TCHAR* lines[6]; 
    155161        size_t i = 0; 
    156162        size_t data_count = (bytes / sizeof(data[0])); 
    157163        unsigned line = 0; 
     164        memset(lines, 0, sizeof(lines)); 
    158165        for (i = 0; i < data_count; ++i) { 
    159166            if (data[i] == _T('\r')) { 
     
    171178            } 
    172179        } 
    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); 
    176190     
    177     { 
    178         TCHAR* pid_string; 
     191    if (pid_string) { 
    179192        int i = 0; 
    180         pid_string = lines[0]; 
    181193        for (i = 0; pid_string[i]; ++i) { 
    182194            if (pid_string[i] < _T('0') || _T('9') < pid_string[i]) { 
     
    189201    } 
    190202 
    191  
    192     {    
     203    if (clean_after) { 
    193204        TCHAR comspec[MAX_PATH]; 
    194205        TCHAR rd_command[] = _T("\"%s\" /c rd /s /q \"%s\""); 
     
    198209        } 
    199210 
    200         clean_command_len = lstrlen(comspec) + lstrlen(rd_command) + lstrlen(lines[4]); 
     211        clean_command_len = lstrlen(comspec) + lstrlen(rd_command) + lstrlen(clean_after); 
    201212        clean_command = (TCHAR*)HeapAlloc(GetProcessHeap(),  
    202213            HEAP_ZERO_MEMORY, clean_command_len * sizeof(TCHAR)); 
     
    204215            goto clean_up; 
    205216        } 
    206         wsprintf(clean_command, rd_command, comspec, lines[4]);  
     217        wsprintf(clean_command, rd_command, comspec, clean_after);  
    207218    } 
    208219 
     
    215226    AUI_Debug(L"start copy\n"); 
    216227 
    217     if (CopyDirectory(lines[1], lines[2])) { 
     228    if (CopyDirectory(update_from, update_to)) { 
    218229        complete = 1; 
    219230    } 
    220231 
    221232clean_up: 
    222     if (lines[3] && lines[4]) { 
     233    if (new_program && new_program_cd) { 
    223234        TCHAR* arg = NULL; 
    224235        TCHAR command_format[] = _T("\"%s\" %s"); 
     
    233244        } 
    234245        command_len = lstrlen(command_format); 
    235         command_len += lstrlen(lines[3]); 
     246        command_len += lstrlen(new_program); 
    236247        command_len += lstrlen(arg); 
    237248 
    238249        command = (TCHAR*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (unsigned)command_len * sizeof(TCHAR)); 
    239250        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) { 
    245256        STARTUPINFO si; 
    246257        PROCESS_INFORMATION pi; 
     
    250261        memset(&pi, 0, sizeof(pi)); 
    251262 
    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); 
    253264        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); 
    255266 
    256267        CloseHandle(pi.hThread); 
     
    269280        si.wShowWindow = SW_HIDE;  
    270281        memset(&pi, 0, sizeof(pi)); 
     282        AUI_Debug(_T("CreateProcess(del): command=%s, cd=%s\n"), clean_command, temp_path); 
    271283        CreateProcess(NULL, clean_command, NULL, NULL, FALSE, 0, NULL, temp_path, &si, &pi); 
    272284        /* 
     
    276288    } 
    277289 
     290 
    278291    /* 
    279292    if (data) {