From: kramm Date: Tue, 10 Jun 2008 10:46:27 +0000 (+0000) Subject: added 'remove extra files' implementation X-Git-Tag: buttons-working~130 X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=commitdiff_plain;h=b573148ab773760a3a78d526d1e020971bb0faca added 'remove extra files' implementation --- diff --git a/installer/installer.c b/installer/installer.c index 78f4fc3..f0f7b25 100644 --- a/installer/installer.c +++ b/installer/installer.c @@ -612,6 +612,55 @@ BOOL CALLBACK PropertySheetFunc4(HWND hwnd, UINT message, WPARAM wParam, LPARAM #ifdef DEINSTALL +void findfiles(char*path, int*pos, char*data, int len, char del) +{ + WIN32_FIND_DATA findFileData; + HANDLE hFind = FindFirstFile(concatPaths(path, "*"), &findFileData); + if(hFind == INVALID_HANDLE_VALUE) + return; + do { + if(findFileData.cFileName[0] == '.' && + (findFileData.cFileName[0] == '.' || findFileData.cFileName == '\0')) + continue; + char*f = concatPaths(path, findFileData.cFileName); + if(findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + findfiles(f, pos, data, len, del); + if(del) { + RemoveDirectory(f); + } + } else { + int l = strlen(f); + + /* don't list the uninstaller as file- it's going to be removed *after* + everything else is done */ + char*uninstaller="uninstall.exe"; + int ll = strlen(uninstaller); + if(l>=ll) { + if(!strcasecmp(&f[l-ll],uninstaller)) { + continue; + } + } + + if(data) { + if(*pos+l <= len) { + memcpy(&data[*pos], f, l);(*pos)+=l; + data[(*pos)++] = '\r'; + data[(*pos)++] = '\n'; + data[(*pos)] = 0; + } + } else { + (*pos) += l+2; + } + if(del) { + DeleteFile(f); + } + } + } while(FindNextFile(hFind, &findFileData)); + FindClose(hFind); +} + +static char*extrafiles = 0; + BOOL CALLBACK PropertySheetFunc5(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { HWND dialog = GetParent(hwnd); if(message == WM_INITDIALOG) { @@ -623,8 +672,10 @@ BOOL CALLBACK PropertySheetFunc5(HWND hwnd, UINT message, WPARAM wParam, LPARAM if(!list) { list = readFileList(concatPaths(install_path, "uninstall.ini")); if(!list) { - MessageBox(0, "Couldn't determine installed files list- did you run uninstall twice?", INSTALLER_NAME, MB_OK); - exit(-1); + //Don't abort. If there's still something there, it'll be catched by the "extra files" + //functionality later + //MessageBox(0, "Couldn't determine installed files list- did you run uninstall twice?", INSTALLER_NAME, MB_OK); + //exit(-1); } } filelist_t* l = list; @@ -648,58 +699,26 @@ BOOL CALLBACK PropertySheetFunc5(HWND hwnd, UINT message, WPARAM wParam, LPARAM num++;l = l->next; } + int len = 0; + findfiles(install_path, &len, 0, 0, 0); + if(len) { + extrafiles = malloc(len); + int pos = 0; + findfiles(install_path, &pos, extrafiles, len, 0); + } else { + PropSheet_RemovePage(dialog, 1, 0); + } return 0; } return PropertySheetFuncCommon(hwnd, message, wParam, lParam, PSWIZB_BACK|PSWIZB_NEXT); } -void findfiles(char*path, int*pos, char*data, int len, char del) -{ - WIN32_FIND_DATA findFileData; - HANDLE hFind = FindFirstFile(concatPaths(path, "*"), &findFileData); - if(hFind == INVALID_HANDLE_VALUE) - return; - do { - if(findFileData.cFileName[0] == '.' && - (findFileData.cFileName[0] == '.' || findFileData.cFileName == '\0')) - continue; - char*f = concatPaths(path, findFileData.cFileName); - if(findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { - findfiles(f, pos, data, len, del); - if(del) { - RemoveDirectory(f); - } - } else { - int l = strlen(f); - if(data) { - if(*pos+l <= len) { - memcpy(&data[*pos], f, l);(*pos)+=l; - data[(*pos)++] = '\r'; - data[(*pos)++] = '\n'; - } - } else { - (*pos) += l+2; - } - if(del) { - DeleteFile(f); - } - } - } while(FindNextFile(hFind, &findFileData)); - FindClose(hFind); -} - BOOL CALLBACK PropertySheetFunc6(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { if(message == WM_INITDIALOG) { SendDlgItemMessage(hwnd, IDC_DELETEEXTRA, BM_SETCHECK, config_deleteextra, 0); - - int len = 0; - - findfiles(install_path, &len, 0, 0, 0); - char*data = malloc(len); - int pos = 0; - findfiles(install_path, &pos, data, len, 0); - - SetDlgItemText(hwnd, IDC_FILELIST, data); + if(extrafiles) { + SetDlgItemText(hwnd, IDC_FILELIST, extrafiles); + } } if(message == WM_COMMAND) { if((wParam&0xffff) == IDC_DELETEEXTRA) { diff --git a/installer/installer.h b/installer/installer.h index aed9eb0..13dba0f 100644 --- a/installer/installer.h +++ b/installer/installer.h @@ -1,22 +1,27 @@ -#define IDD_INSTALLDIR 1001 -#define IDD_LICENSE 1002 -#define IDD_PROGRESS 1003 -#define IDD_FINISH 1004 +#define IDD_INSTALLDIR 1101 +#define IDD_LICENSE 1102 +#define IDD_PROGRESS 1103 +#define IDD_FINISH 1104 +#define IDD_SURE 1105 +#define IDD_EXTRAFILES 1106 +#define IDD_DEINSTALLED 1107 -#define IDC_ALLUSERS 1012 -#define IDC_CURRENTUSER 1013 +#define IDC_ALLUSERS 1201 +#define IDC_CURRENTUSER 1202 -#define IDC_SPACE1 1032 -#define IDC_SPACE2 1033 +#define IDC_SPACE1 1301 +#define IDC_SPACE2 1302 #define IDC_TITLE 1002 #define IDC_LICENSE 1003 -#define IDC_BITMAP 1004 +#define IDC_FILELIST 1004 +#define IDC_BITMAP 1005 #define IDC_PATH 1006 #define IDC_INSTALL_PATH 1007 #define IDC_PROGRESS 1008 #define IDC_INFO 1009 #define IDC_STARTMENU 1010 #define IDC_DESKTOP 1011 -#define IDC_BROWSE 1011 +#define IDC_BROWSE 1012 +#define IDC_DELETEEXTRA 1013 #define IDC_STATIC (-1)