2010-04-29 02:34:43 +02:00
|
|
|
// ==============================================================
|
|
|
|
// This file is part of Glest Shared Library (www.glest.org)
|
|
|
|
//
|
2011-12-14 08:40:48 +01:00
|
|
|
// Copyright (C) 2001-2008 Martiño Figueroa
|
2010-04-29 02:34:43 +02:00
|
|
|
//
|
|
|
|
// You can redistribute this code and/or modify it under
|
|
|
|
// the terms of the GNU General Public License as published
|
|
|
|
// by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version
|
|
|
|
// ==============================================================
|
|
|
|
|
|
|
|
#ifndef _SHARED_UTIL_CHECKSUM_H_
|
|
|
|
#define _SHARED_UTIL_CHECKSUM_H_
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <map>
|
2012-04-20 03:04:05 +02:00
|
|
|
#include "data_types.h"
|
2011-03-23 01:49:21 +01:00
|
|
|
#include "thread.h"
|
2010-09-07 07:25:40 +02:00
|
|
|
#include "leak_dumper.h"
|
2010-04-29 02:34:43 +02:00
|
|
|
|
|
|
|
using std::string;
|
2011-03-23 01:49:21 +01:00
|
|
|
using namespace Shared::Platform;
|
2010-04-29 02:34:43 +02:00
|
|
|
|
|
|
|
namespace Shared{ namespace Util{
|
|
|
|
|
|
|
|
// =====================================================
|
|
|
|
// class Checksum
|
|
|
|
// =====================================================
|
|
|
|
|
2011-01-15 05:13:15 +01:00
|
|
|
class Checksum {
|
2010-04-29 02:34:43 +02:00
|
|
|
private:
|
2012-07-07 04:46:57 +02:00
|
|
|
uint32 sum;
|
2010-04-29 02:34:43 +02:00
|
|
|
int32 r;
|
|
|
|
int32 c1;
|
|
|
|
int32 c2;
|
2012-07-07 04:46:57 +02:00
|
|
|
std::map<string,uint32> fileList;
|
2011-03-23 01:49:21 +01:00
|
|
|
|
|
|
|
static Mutex fileListCacheSynchAccessor;
|
2012-07-07 04:46:57 +02:00
|
|
|
static std::map<string,uint32> fileListCache;
|
2010-04-29 02:34:43 +02:00
|
|
|
|
2012-07-07 04:46:57 +02:00
|
|
|
void addSum(uint32 value);
|
2011-01-10 01:33:40 +01:00
|
|
|
bool addFileToSum(const string &path);
|
2010-04-29 02:34:43 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
Checksum();
|
|
|
|
|
2012-07-07 04:46:57 +02:00
|
|
|
uint32 getSum();
|
|
|
|
uint32 getFinalFileListSum();
|
|
|
|
uint32 getFileCount();
|
2010-04-29 02:34:43 +02:00
|
|
|
|
2012-07-07 04:46:57 +02:00
|
|
|
//uint32 addByte(int8 value);
|
|
|
|
uint32 addByte(const char value);
|
|
|
|
uint32 addBytes(const void *_data, size_t _size);
|
2010-04-29 02:34:43 +02:00
|
|
|
void addString(const string &value);
|
2012-07-07 04:46:57 +02:00
|
|
|
uint32 addInt(const int32 &value);
|
2013-10-17 08:36:28 +02:00
|
|
|
uint32 addUInt(const uint32 &value);
|
2013-09-12 05:33:43 +02:00
|
|
|
uint32 addInt64(const int64 &value);
|
2010-04-29 02:34:43 +02:00
|
|
|
void addFile(const string &path);
|
2011-01-10 01:33:40 +01:00
|
|
|
|
|
|
|
static void removeFileFromCache(const string file);
|
|
|
|
static void clearFileCache();
|
2010-04-29 02:34:43 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}}//end namespace
|
|
|
|
|
|
|
|
#endif
|