+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);
+ /* always try to remove directories- if they are empty, this
+ will work, and they won't prevent superdirectory deletion later */
+ 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;
+