summaryrefslogtreecommitdiffstats
path: root/converter/source/main.cpp
blob: 5df378cd697f3e4ac4bbb4c426923fa7d760b7de (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "MemoryLeak.h"

#include <iostream>
#include "cNBTData.h"
#include "cTimer.h"
#include "cQuicksort.h"
#include "cDeNotch.h"
#ifdef _WIN32
#include "wdirent.h"
#else
#include <dirent.h>
#endif

int main () 
{

#ifdef _DEBUG
	_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif

	cTimer Timer;
	clock_t progBegin = clock(); //start main program timer
	std::string dir;
	DIR* dp;
	struct dirent *entry;
	int found;
	std::string entrys;
	std::string str2;
	std::string str3;
	std::string filexPos;
	std::string filezPos;
	std::string pak_name;
	//string* dir_array;
	int dir_num_files = 0;
	int ctr = 0;

	if(dp = opendir("./"))
	{
		while(entry = readdir(dp))
		{
			entrys = entry->d_name;
			found = entrys.find(".mcr");
			if ( (found!=std::string::npos) )
			{
				str2 = entrys.substr (2,sizeof(entrys));
				filexPos = str2.substr (0,(int)str2.find("."));
				str3 = str2.substr ((int)str2.find(".")+1, sizeof(str2));
				filezPos = str3.substr (0,(int)str3.find("."));
				pak_name = "X" + filexPos + "_Z" + filezPos + ".pak";

				clock_t begin=clock(); //start execution timer

				cDeNotch DeNotch;
				DeNotch.Converter ( entrys, pak_name );


				clock_t end=clock();
				std::cout << "Time to convert chunk: " << double(Timer.diffclock(end,begin)) << " Seconds"<< std::endl;
			}
		}
		closedir(dp);
	}
	clock_t progEnd = clock(); //end main program timer
	std::cout << "Time to complete converter: " << double(Timer.diffclock(progEnd,progBegin)) << " Seconds"<< std::endl;

#ifdef _DEBUG
	_CrtDumpMemoryLeaks();
#endif

#ifdef _WIN32
	system("PAUSE");
#endif

	return 0;
};