From 28f8ef3b0fdd838ee3aa1ba24786b57205baa3e8 Mon Sep 17 00:00:00 2001 From: mateuszb Date: Mon, 8 Feb 2010 14:39:19 +0000 Subject: [PATCH] * two missing files to previous commit --- hch/CCampaignHandler.cpp | 51 ++++++++++++++++++++++++++++++++++++++++ hch/CCampaignHandler.h | 23 ++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 hch/CCampaignHandler.cpp create mode 100644 hch/CCampaignHandler.h diff --git a/hch/CCampaignHandler.cpp b/hch/CCampaignHandler.cpp new file mode 100644 index 000000000..75e601368 --- /dev/null +++ b/hch/CCampaignHandler.cpp @@ -0,0 +1,51 @@ +#define VCMI_DLL + +#include "CCampaignHandler.h" +#include +#include +#include + + +namespace fs = boost::filesystem; + + +std::vector CCampaignHandler::getCampaignHeaders() +{ + std::vector 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; +} \ No newline at end of file diff --git a/hch/CCampaignHandler.h b/hch/CCampaignHandler.h new file mode 100644 index 000000000..34e71a3a4 --- /dev/null +++ b/hch/CCampaignHandler.h @@ -0,0 +1,23 @@ +#ifndef __CCAMPAIGNHANDLER_H__ +#define __CCAMPAIGNHANDLER_H__ + +#include "../global.h" +#include +#include + + +class DLL_EXPORT CCampaignHeader +{ + +}; + + +class DLL_EXPORT CCampaignHandler +{ + CCampaignHeader getHeader( const std::string & name, int size ); +public: + std::vector getCampaignHeaders(); +}; + + +#endif __CCAMPAIGNHANDLER_H__ \ No newline at end of file