diff --git a/Source/capture.cpp b/Source/capture.cpp index fe164b395..0f9f3ee07 100644 --- a/Source/capture.cpp +++ b/Source/capture.cpp @@ -134,27 +134,17 @@ BYTE *CaptureEnc(BYTE *src, BYTE *dst, int width) HANDLE CaptureFile(char *dst_path) { - BOOLEAN num_used[100]; - int free_num, hFind; - struct _finddata_t finder; - - memset(num_used, FALSE, sizeof(num_used)); - hFind = _findfirst("screen??.PCX", &finder); - if (hFind != -1) { - do { - if (isdigit(finder.name[6]) && isdigit(finder.name[7])) { - free_num = 10 * (finder.name[6] - '0'); - free_num += (finder.name[7] - '0'); - num_used[free_num] = TRUE; - } - } while (_findnext(hFind, &finder) == 0); - } + int len = GetModuleFileNameA(ghInst, dst_path, MAX_PATH); - for (free_num = 0; free_num < 100; free_num++) { - if (!num_used[free_num]) { - sprintf(dst_path, "screen%02d.PCX", free_num); + for (int i = 0; i <= 99; i++) { + sprintf(&dst_path[len], "screen%02d.PCX", i); + FILE *file = fopen(dst_path, "r"); + + if (file == NULL) { return CreateFile(dst_path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); } + + fclose(file); } return INVALID_HANDLE_VALUE;