Debian Codegraph @

tools/cheatsConverter/src/main.cpp

raw
1 /* Cheats converter
2
3 Copyright 2009 DeSmuME team
4
5 This file is part of DeSmuME
6
7 DeSmuME is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 DeSmuME is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with DeSmuME; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21 // first release: 19/12/2009
22
23 #include <windows.h>
24 #include <stdio.h>
25 #include <conio.h>
26 #include "common.h"
27 #include "convert.h"
28
29 int main()
30 {
31 WIN32_FIND_DATA FindFileData;
32 HANDLE hFind = NULL;
33 u32 count = 0;
34 char buf[MAX_PATH] = {0};
35
36 SetConsoleCP(GetACP());
37 SetConsoleOutputCP(GetACP());
38
39 printf("DeSmuME cheats file converter\n");
40 printf("Copyright (C) 2009 by DeSmuME Team\n");
41 printf("Version 0.1\n");
42 printf("\n");
43
44 printf("All files (.cht) of deception in a current directory will be renamed\n");
45 printf("Are you sure?");
46
47 int ch = 0;
48 do
49 {
50 ch = getch();
51 if ((ch == 'N') || (ch == 'n'))
52 {
53 printf(" no\n\n");
54 return 2;
55 }
56 } while ((ch != 'Y') && (ch != 'y'));
57 printf(" yes\n");
58 printf("\n");
59
60 hFind = FindFirstFile("*.dct", &FindFileData);
61 if (hFind == INVALID_HANDLE_VALUE)
62 {
63 printf("%s\n", error());
64 return 1;
65 }
66
67 do
68 {
69 if (!(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
70 {
71 if (strncmp(FindFileData.cFileName + (strlen(FindFileData.cFileName) - 4), ".dct", 4) != 0)
72 continue;
73
74 printf("%s", FindFileData.cFileName);
75 sprintf(buf, ".\\%s", FindFileData.cFileName);
76 if (convertFile(buf))
77 {
78 printf(" - Ok\n");
79 count++;
80 }
81 else
82 printf(" - Failed\n");
83 }
84
85 } while (FindNextFile(hFind, &FindFileData));
86 FindClose(hFind);
87 printf("\nConverted %i files\n\n", count);
88 printf("Done\n\n");
89
90 return 0;
91 }