Zcalanie ręczne. Jak git nie chce po dobroci to będzie siłą
This commit is contained in:
parent
690e5278c5
commit
3bf98ba472
22 changed files with 790 additions and 457 deletions
51
ChunkManager.h
Normal file
51
ChunkManager.h
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
#include "EncryptionManager.h"
|
||||
#include "CompressionManager.h"
|
||||
|
||||
#define BLOCK_SIZE 131072 // 128KB
|
||||
|
||||
class ChunkManager
|
||||
{
|
||||
public:
|
||||
ChunkManager(EncryptionManager& em);
|
||||
~ChunkManager();
|
||||
|
||||
// Kompresja danych
|
||||
std::vector<char> chunked(const std::vector<char>&, const bool&, const bool&);
|
||||
|
||||
// Dekompresja
|
||||
std::vector<char> dechunked(const std::vector<char>&, const bool&, const bool&);
|
||||
|
||||
private:
|
||||
EncryptionManager eman;
|
||||
CompressionManager cman;
|
||||
|
||||
// Przekonwertuj zmienn¹ na ci¹g na vector
|
||||
template <typename T>
|
||||
void addIntToVector(std::vector<char>& vec, const T& val)
|
||||
{
|
||||
size_t tmpSize = vec.size();
|
||||
vec.resize(tmpSize + sizeof(val));
|
||||
std::memcpy(vec.data() + tmpSize, &val, sizeof(val));
|
||||
}
|
||||
|
||||
// Pobierz zmienn¹ z vectora
|
||||
template <typename T>
|
||||
T getIntFromVector(const std::vector<char>& vec, size_t& offset)
|
||||
{
|
||||
T tmp{};
|
||||
std::memcpy(&tmp, vec.data() + offset, sizeof(tmp));
|
||||
offset += sizeof(tmp);
|
||||
|
||||
return tmp;
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue