Sfoglia il codice sorgente

* two missing files to previous commit

mateuszb 15 anni fa
parent
commit
28f8ef3b0f
2 ha cambiato i file con 74 aggiunte e 0 eliminazioni
  1. 51 0
      hch/CCampaignHandler.cpp
  2. 23 0
      hch/CCampaignHandler.h

+ 51 - 0
hch/CCampaignHandler.cpp

@@ -0,0 +1,51 @@
+#define VCMI_DLL
+
+#include "CCampaignHandler.h"
+#include <boost/filesystem.hpp>
+#include <stdio.h>
+#include <boost/algorithm/string/predicate.hpp>
+
+
+namespace fs = boost::filesystem;
+
+
+std::vector<CCampaignHeader> CCampaignHandler::getCampaignHeaders()
+{
+	std::vector<CCampaignHeader> ret;
+
+	std::string dirname = DATA_DIR "/Maps";
+	std::string ext = ".h3c";
+
+	if(!boost::filesystem::exists(dirname))
+	{
+		tlog1 << "Cannot find " << dirname << " directory!\n";
+	}
+
+	fs::path tie(dirname);
+	fs::directory_iterator end_iter;
+	for ( fs::directory_iterator file (tie); file!=end_iter; ++file )
+	{
+		if(fs::is_regular_file(file->status())
+			&& boost::ends_with(file->path().filename(), ext))
+		{
+			ret.push_back( getHeader( file->path().string(), fs::file_size( file->path() ) ) );
+		}
+	}
+
+	return ret;
+}
+
+CCampaignHeader CCampaignHandler::getHeader( const std::string & name, int size )
+{
+	FILE * input = fopen(name.c_str(), "rb");
+	char * tab = new char[size];
+	fread(tab, 1, size, input);
+
+	CCampaignHeader ret;
+
+
+
+	delete [] tab;
+
+	return ret;
+}

+ 23 - 0
hch/CCampaignHandler.h

@@ -0,0 +1,23 @@
+#ifndef __CCAMPAIGNHANDLER_H__
+#define __CCAMPAIGNHANDLER_H__
+
+#include "../global.h"
+#include <string>
+#include <vector>
+
+
+class DLL_EXPORT CCampaignHeader
+{
+
+};
+
+
+class DLL_EXPORT CCampaignHandler
+{
+	CCampaignHeader getHeader( const std::string & name, int size );
+public:
+	std::vector<CCampaignHeader> getCampaignHeaders();
+};
+
+
+#endif __CCAMPAIGNHANDLER_H__