mirror of
https://github.com/usatiuk/backup.git
synced 2025-10-26 09:27:48 +01:00
proper cmake
This commit is contained in:
8
.idea/.gitignore
generated
vendored
8
.idea/.gitignore
generated
vendored
@@ -1,8 +0,0 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
1
.idea/.name
generated
1
.idea/.name
generated
@@ -1 +0,0 @@
|
||||
sembackup
|
||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -11,18 +11,9 @@ add_link_options(-Ofast)
|
||||
#add_link_options(-fsanitize=address -fsanitize=undefined -fno-sanitize-recover)
|
||||
#add_link_options(-rdynamic)
|
||||
|
||||
project(sembackup)
|
||||
project(backup)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
enable_testing()
|
||||
|
||||
find_package(OpenSSL REQUIRED)
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
||||
add_executable(sembackup src/Config.cpp src/main.cpp src/repo/Object.cpp src/repo/Object.h src/repo/Repository.cpp src/repo/Repository.h src/repo/FileRepository.cpp src/repo/FileRepository.h src/repo/objects/Archive.cpp src/repo/objects/Archive.h src/repo/objects/File.cpp src/repo/objects/File.h src/repo/objects/Chunk.cpp src/repo/objects/Chunk.h src/repo/Serialize.h src/chunkers/Chunker.cpp src/chunkers/Chunker.h src/chunkers/ConstChunker.cpp src/chunkers/ConstChunker.h src/crypto/MD5.cpp src/crypto/MD5.h src/change_detectors/ChangeDetector.cpp src/change_detectors/ChangeDetector.h src/change_detectors/SizeChangeDetector.cpp src/change_detectors/SizeChangeDetector.h src/change_detectors/EditTimeChangeDetector.cpp src/change_detectors/EditTimeChangeDetector.h src/change_detectors/ChangeDetectorFactory.cpp src/change_detectors/ChangeDetectorFactory.h src/Signals.h src/Signals.cpp src/filters/Filter.cpp src/filters/Filter.h src/filters/FilterShift.cpp src/filters/FilterShift.h src/filters/FilterShiftSecret.cpp src/filters/FilterShiftSecret.h src/repo/objects/FileBuffer.cpp src/repo/objects/FileBuffer.h src/filters/FilterZlib.cpp src/filters/FilterZlib.h src/filters/FilterAES.cpp src/filters/FilterAES.h src/chunkers/BuzhashChunker.cpp src/chunkers/BuzhashChunker.h src/chunkers/Buzhash.cpp src/chunkers/Buzhash.h src/crypto/AES.cpp src/crypto/AES.h src/chunkers/ChunkerFactory.cpp src/chunkers/ChunkerFactory.h src/Exception.cpp src/Exception.h src/filters/FilterFactory.h src/filters/FilterContainer.h src/filters/FilterFactory.cpp src/filters/FilterContainer.cpp src/change_detectors/ChangeDetectorContainer.cpp src/change_detectors/ChangeDetectorContainer.h src/Progress.cpp src/Progress.h src/change_detectors/ContentsChangeDetector.cpp src/change_detectors/ContentsChangeDetector.h src/change_detectors/ComparableFile.cpp src/change_detectors/ComparableFile.h src/RunningAverage.cpp src/RunningAverage.h src/Diff.cpp src/Diff.h src/ThreadPool.cpp src/filters/CheckFilter.cpp src/filters/CheckFilter.h src/crypto/CRC32.cpp src/crypto/CRC32.h src/change_detectors/TypeChangeDetector.cpp src/change_detectors/TypeChangeDetector.h src/RunningDiffAverage.cpp src/RunningDiffAverage.h src/BytesFormatter.cpp src/BytesFormatter.h src/Logger.cpp src/Logger.h src/Context.h src/commands/Command.cpp src/commands/Command.h src/commands/CommandRun.cpp src/commands/CommandRun.h src/commands/CommandsCommon.cpp src/commands/CommandsCommon.h src/commands/CommandRestore.cpp src/commands/CommandRestore.h src/commands/CommandDiff.cpp src/commands/CommandDiff.h src/commands/CommandList.cpp src/commands/CommandList.h src/commands/CommandListFiles.cpp src/commands/CommandListFiles.h)
|
||||
add_executable(test src/Config.cpp src/crypto/MD5.cpp src/change_detectors/EditTimeChangeDetector.cpp tests/runTests.cpp tests/utils/Runnable.cpp tests/utils/HelpfulAssertTest.cpp tests/utils/HelpfulAssertTest.h tests/utils/TestGroup.cpp tests/utils/TestGroup.h tests/utils/Test.cpp tests/utils/Test.h tests/utils/TestGroupGenerator.h src/repo/Object.cpp src/repo/Object.h src/repo/Repository.cpp src/repo/Repository.h src/repo/FileRepository.cpp src/repo/FileRepository.h src/repo/objects/Archive.cpp src/repo/objects/Archive.h src/repo/objects/File.cpp src/repo/objects/File.h src/repo/objects/Chunk.cpp src/repo/objects/Chunk.h tests/repo/ChunkTest.cpp tests/repo/ChunkTest.h tests/repo/FileRepositoryTest.cpp tests/repo/FileRepositoryTest.h tests/utils/Cleaner.cpp tests/utils/Cleaner.h src/repo/Serialize.h src/chunkers/Chunker.cpp src/chunkers/Chunker.h src/chunkers/ConstChunker.cpp src/chunkers/ConstChunker.h tests/crypto/MD5Test.cpp tests/crypto/MD5Test.h tests/fulltests/FullTest.cpp tests/fulltests/FullTest.h src/change_detectors/ChangeDetector.cpp src/change_detectors/ChangeDetector.h src/change_detectors/SizeChangeDetector.cpp src/change_detectors/SizeChangeDetector.h src/change_detectors/ChangeDetectorFactory.cpp src/change_detectors/ChangeDetectorFactory.h src/filters/Filter.cpp src/filters/Filter.h src/filters/FilterShift.cpp src/filters/FilterShift.h src/filters/FilterShiftSecret.cpp src/filters/FilterShiftSecret.h src/repo/objects/FileBuffer.cpp src/repo/objects/FileBuffer.h src/filters/FilterZlib.cpp src/filters/FilterZlib.h src/filters/FilterAES.cpp src/filters/FilterAES.h src/chunkers/BuzhashChunker.cpp src/chunkers/BuzhashChunker.h src/chunkers/Buzhash.cpp src/chunkers/Buzhash.h tests/BuzhashTest.cpp tests/BuzhashTest.h src/crypto/AES.cpp src/crypto/AES.h tests/crypto/AESTest.cpp tests/crypto/AESTest.h src/chunkers/ChunkerFactory.cpp src/chunkers/ChunkerFactory.h src/Exception.cpp src/Exception.h src/filters/FilterFactory.h src/filters/FilterContainer.h src/filters/FilterFactory.cpp src/filters/FilterContainer.cpp src/change_detectors/ChangeDetectorContainer.cpp src/change_detectors/ChangeDetectorContainer.h src/Progress.cpp src/Progress.h src/change_detectors/ContentsChangeDetector.cpp src/change_detectors/ContentsChangeDetector.h src/change_detectors/ComparableFile.cpp src/change_detectors/ComparableFile.h src/RunningAverage.cpp src/RunningAverage.h src/Diff.cpp src/Diff.h src/ThreadPool.cpp tests/CLITestWrapper.cpp tests/CLITestWrapper.h src/filters/CheckFilter.cpp src/filters/CheckFilter.h src/crypto/CRC32.cpp src/crypto/CRC32.h src/change_detectors/TypeChangeDetector.cpp src/change_detectors/TypeChangeDetector.h src/RunningDiffAverage.cpp src/RunningDiffAverage.h src/BytesFormatter.cpp src/BytesFormatter.h src/Logger.cpp src/Logger.h src/Context.h src/commands/Command.cpp src/commands/Command.h src/commands/CommandRun.cpp src/commands/CommandRun.h src/commands/CommandsCommon.cpp src/commands/CommandsCommon.h src/commands/CommandRestore.cpp src/commands/CommandRestore.h src/commands/CommandList.cpp src/commands/CommandList.h src/commands/CommandListFiles.cpp src/commands/CommandListFiles.h)
|
||||
|
||||
add_dependencies(test sembackup)
|
||||
|
||||
target_link_libraries(sembackup OpenSSL::SSL ZLIB::ZLIB)
|
||||
target_link_libraries(test OpenSSL::SSL ZLIB::ZLIB)
|
||||
target_compile_definitions(test PUBLIC TEST)
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(tests)
|
||||
|
||||
15
src/CMakeLists.txt
Normal file
15
src/CMakeLists.txt
Normal file
@@ -0,0 +1,15 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
add_subdirectory(change_detectors)
|
||||
add_subdirectory(chunkers)
|
||||
add_subdirectory(commands)
|
||||
add_subdirectory(crypto)
|
||||
add_subdirectory(filters)
|
||||
add_subdirectory(repo)
|
||||
add_subdirectory(utils)
|
||||
|
||||
add_executable(backup main.cpp)
|
||||
target_link_libraries(backup PRIVATE change_detectors chunkers commands crypto filters repo utils)
|
||||
7
src/change_detectors/CMakeLists.txt
Normal file
7
src/change_detectors/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
add_library(change_detectors srcs/ChangeDetector.cpp srcs/ChangeDetectorContainer.cpp srcs/ChangeDetectorFactory.cpp srcs/ComparableFile.cpp srcs/ContentsChangeDetector.cpp srcs/EditTimeChangeDetector.cpp srcs/SizeChangeDetector.cpp srcs/TypeChangeDetector.cpp)
|
||||
|
||||
target_include_directories(change_detectors PUBLIC includes)
|
||||
|
||||
target_link_libraries(change_detectors utils)
|
||||
@@ -8,9 +8,9 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "../Config.h"
|
||||
#include "ChangeDetector.h"
|
||||
#include "ChangeDetectorContainer.h"
|
||||
#include "Config.h"
|
||||
|
||||
/// Factory class for ChangeDetector
|
||||
/** Can create either a vector of ChangeDetector%s according to Config,
|
||||
@@ -9,8 +9,8 @@
|
||||
#include <functional>
|
||||
#include <streambuf>
|
||||
|
||||
#include "../repo/Repository.h"
|
||||
#include "../repo/objects/File.h"
|
||||
#include "../../repo/includes/Repository.h"
|
||||
#include "../../repo/includes/objects/File.h"
|
||||
|
||||
/// Helper class to allow comparing files from different sources
|
||||
/**
|
||||
@@ -2,6 +2,6 @@
|
||||
// Created by Stepan Usatiuk on 16.04.2023.
|
||||
//
|
||||
|
||||
#include "ChangeDetector.h"
|
||||
#include "../includes/ChangeDetector.h"
|
||||
|
||||
ChangeDetector::~ChangeDetector() = default;
|
||||
@@ -2,7 +2,7 @@
|
||||
// Created by Stepan Usatiuk on 04.05.2023.
|
||||
//
|
||||
|
||||
#include "ChangeDetectorContainer.h"
|
||||
#include "../includes/ChangeDetectorContainer.h"
|
||||
|
||||
#include <functional>
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
// Created by Stepan Usatiuk on 16.04.2023.
|
||||
//
|
||||
|
||||
#include "ChangeDetectorFactory.h"
|
||||
#include "../includes/ChangeDetectorFactory.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "../Exception.h"
|
||||
#include "ContentsChangeDetector.h"
|
||||
#include "EditTimeChangeDetector.h"
|
||||
#include "SizeChangeDetector.h"
|
||||
#include "TypeChangeDetector.h"
|
||||
#include "../includes/ContentsChangeDetector.h"
|
||||
#include "../includes/EditTimeChangeDetector.h"
|
||||
#include "../includes/SizeChangeDetector.h"
|
||||
#include "../includes/TypeChangeDetector.h"
|
||||
#include "Exception.h"
|
||||
|
||||
std::unique_ptr<ChangeDetector> ChangeDetectorFactory::getChangeDetector(const std::string &type) {
|
||||
if (type == "etime") {
|
||||
@@ -3,13 +3,13 @@
|
||||
//
|
||||
|
||||
|
||||
#include "ComparableFile.h"
|
||||
#include "../includes/ComparableFile.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include "../Exception.h"
|
||||
#include "../repo/objects/FileBuffer.h"
|
||||
#include "../../repo/includes/objects/FileBuffer.h"
|
||||
#include "../../utils/includes/Exception.h"
|
||||
|
||||
ComparableFile::ComparableFile(const File &file, const Repository *repo)
|
||||
: path(file.name),
|
||||
@@ -2,7 +2,7 @@
|
||||
// Created by Stepan Usatiuk on 05.05.2023.
|
||||
//
|
||||
|
||||
#include "ContentsChangeDetector.h"
|
||||
#include "../includes/ContentsChangeDetector.h"
|
||||
|
||||
#include <iterator>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Created by Stepan Usatiuk on 16.04.2023.
|
||||
//
|
||||
|
||||
#include "EditTimeChangeDetector.h"
|
||||
#include "../includes/EditTimeChangeDetector.h"
|
||||
|
||||
bool EditTimeChangeDetector::check(const ComparableFile &f1, const ComparableFile &f2) const {
|
||||
return f1.mtime != f2.mtime;
|
||||
@@ -2,7 +2,7 @@
|
||||
// Created by Stepan Usatiuk on 16.04.2023.
|
||||
//
|
||||
|
||||
#include "SizeChangeDetector.h"
|
||||
#include "../includes/SizeChangeDetector.h"
|
||||
|
||||
bool SizeChangeDetector::check(const ComparableFile &f1, const ComparableFile &f2) const {
|
||||
return f1.bytes != f2.bytes;
|
||||
@@ -2,7 +2,7 @@
|
||||
// Created by Stepan Usatiuk on 12.05.2023.
|
||||
//
|
||||
|
||||
#include "TypeChangeDetector.h"
|
||||
#include "../includes/TypeChangeDetector.h"
|
||||
|
||||
bool TypeChangeDetector::check(const ComparableFile &f1, const ComparableFile &f2) const {
|
||||
return f1.type != f2.type;
|
||||
7
src/chunkers/CMakeLists.txt
Normal file
7
src/chunkers/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
add_library(chunkers srcs/Buzhash.cpp srcs/BuzhashChunker.cpp srcs/Chunker.cpp srcs/ChunkerFactory.cpp srcs/ConstChunker.cpp)
|
||||
|
||||
target_include_directories(chunkers PUBLIC includes)
|
||||
|
||||
target_link_libraries(chunkers crypto)
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <memory>
|
||||
#include <streambuf>
|
||||
|
||||
#include "../Config.h"
|
||||
#include "../../utils/includes/Config.h"
|
||||
#include "Chunker.h"
|
||||
|
||||
/// Factory for Chunker%s
|
||||
@@ -2,7 +2,7 @@
|
||||
// Created by Stepan Usatiuk on 26.04.2023.
|
||||
//
|
||||
|
||||
#include "Buzhash.h"
|
||||
#include "../includes/Buzhash.h"
|
||||
|
||||
Buzhash::Buzhash(uint32_t blockSize) : blockSize(blockSize), history() {}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Created by Stepan Usatiuk on 26.04.2023.
|
||||
//
|
||||
|
||||
#include "BuzhashChunker.h"
|
||||
#include "../includes/BuzhashChunker.h"
|
||||
|
||||
#include "../Exception.h"
|
||||
#include "../crypto/MD5.h"
|
||||
#include "../../crypto/includes/MD5.h"
|
||||
#include "../../utils/includes/Exception.h"
|
||||
|
||||
BuzhashChunker::BuzhashChunker(std::streambuf *buf, unsigned long long minBytes, unsigned long long maxBytes, unsigned long long mask, uint32_t window) : Chunker(buf, maxBytes), window(window), minBytes(minBytes), mask(mask), buzhash(window) {}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
// Created by Stepan Usatiuk on 15.04.2023.
|
||||
//
|
||||
|
||||
#include "Chunker.h"
|
||||
#include "../includes/Chunker.h"
|
||||
|
||||
#include "../Exception.h"
|
||||
#include "../../utils/includes/Exception.h"
|
||||
|
||||
Chunker::Chunker(std::streambuf *buf, unsigned long long maxBytes) : buf(buf), maxBytes(maxBytes) {}
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
// Created by Stepan Usatiuk on 30.04.2023.
|
||||
//
|
||||
|
||||
#include "ChunkerFactory.h"
|
||||
#include "../includes/ChunkerFactory.h"
|
||||
|
||||
#include "../Exception.h"
|
||||
#include "BuzhashChunker.h"
|
||||
#include "ConstChunker.h"
|
||||
#include "../../utils/includes/Exception.h"
|
||||
#include "../includes/BuzhashChunker.h"
|
||||
#include "../includes/ConstChunker.h"
|
||||
|
||||
std::unique_ptr<Chunker> ChunkerFactory::getChunker(const Config &config, std::streambuf *buf) {
|
||||
if (config.getStr("chunker") == "const") {
|
||||
@@ -2,10 +2,10 @@
|
||||
// Created by Stepan Usatiuk on 15.04.2023.
|
||||
//
|
||||
|
||||
#include "ConstChunker.h"
|
||||
#include "../includes/ConstChunker.h"
|
||||
|
||||
#include "../Exception.h"
|
||||
#include "../crypto/MD5.h"
|
||||
#include "../../crypto/includes/MD5.h"
|
||||
#include "../../utils/includes/Exception.h"
|
||||
|
||||
ConstChunker::ConstChunker(std::streambuf *buf, unsigned long long maxBytes) : Chunker(buf, maxBytes) {}
|
||||
|
||||
7
src/commands/CMakeLists.txt
Normal file
7
src/commands/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
add_library(commands srcs/Command.cpp srcs/CommandDiff.cpp srcs/CommandList.cpp srcs/CommandListFiles.cpp srcs/CommandRestore.cpp srcs/CommandRun.cpp srcs/CommandsCommon.cpp srcs/Diff.cpp)
|
||||
|
||||
target_include_directories(commands PUBLIC includes)
|
||||
|
||||
target_link_libraries(commands crypto repo chunkers utils change_detectors)
|
||||
@@ -5,7 +5,7 @@
|
||||
#ifndef SEMBACKUP_COMMAND_H
|
||||
#define SEMBACKUP_COMMAND_H
|
||||
|
||||
#include "../Context.h"
|
||||
#include "Context.h"
|
||||
|
||||
/// Abstract base class for some process running with some Context
|
||||
class Command {
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "Command.h"
|
||||
|
||||
#include "../repo/objects/File.h"
|
||||
#include "../../repo/includes/objects/File.h"
|
||||
|
||||
#include "CommandsCommon.h"
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
#ifndef SEMBACKUP_CONTEXT_H
|
||||
#define SEMBACKUP_CONTEXT_H
|
||||
|
||||
#include "Config.h"
|
||||
#include "Logger.h"
|
||||
#include "repo/Repository.h"
|
||||
#include "../../repo/includes/Repository.h"
|
||||
#include "../../utils/includes/Config.h"
|
||||
#include "../../utils/includes/Logger.h"
|
||||
|
||||
struct Context {
|
||||
Logger *logger;
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "change_detectors/ComparableFile.h"
|
||||
#include "../../change_detectors/includes/ComparableFile.h"
|
||||
|
||||
/// Utility class to compute difference between two ComparableFile%s
|
||||
class Diff {
|
||||
@@ -2,7 +2,7 @@
|
||||
// Created by Stepan Usatiuk on 23.05.2023.
|
||||
//
|
||||
|
||||
#include "Command.h"
|
||||
#include "../includes/Command.h"
|
||||
|
||||
Command::Command(std::string name) : name(std::move(name)) {}
|
||||
|
||||
@@ -2,20 +2,20 @@
|
||||
// Created by Stepan Usatiuk on 23.05.2023.
|
||||
//
|
||||
|
||||
#include "CommandDiff.h"
|
||||
#include "../includes/CommandDiff.h"
|
||||
|
||||
#include "../BytesFormatter.h"
|
||||
#include "../Diff.h"
|
||||
#include "../Exception.h"
|
||||
#include "../Progress.h"
|
||||
#include "../RunningDiffAverage.h"
|
||||
#include "../Signals.h"
|
||||
#include "../ThreadPool.h"
|
||||
#include "../change_detectors/ChangeDetectorFactory.h"
|
||||
#include "../chunkers/ChunkerFactory.h"
|
||||
#include "../repo/Serialize.h"
|
||||
#include "../repo/objects/Archive.h"
|
||||
#include "../repo/objects/Chunk.h"
|
||||
#include "../../change_detectors/includes/ChangeDetectorFactory.h"
|
||||
#include "../../chunkers/includes/ChunkerFactory.h"
|
||||
#include "../../repo/includes/Serialize.h"
|
||||
#include "../../repo/includes/objects/Archive.h"
|
||||
#include "../../repo/includes/objects/Chunk.h"
|
||||
#include "../../utils/includes/BytesFormatter.h"
|
||||
#include "../../utils/includes/Exception.h"
|
||||
#include "../../utils/includes/Progress.h"
|
||||
#include "../../utils/includes/RunningDiffAverage.h"
|
||||
#include "../../utils/includes/Signals.h"
|
||||
#include "../../utils/includes/ThreadPool.h"
|
||||
#include "../includes/Diff.h"
|
||||
|
||||
using namespace CommandsCommon;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Created by Stepan Usatiuk on 23.05.2023.
|
||||
//
|
||||
|
||||
#include "CommandList.h"
|
||||
#include "../includes/CommandList.h"
|
||||
|
||||
CommandList::CommandList() : Command("list") {
|
||||
}
|
||||
@@ -2,13 +2,13 @@
|
||||
// Created by Stepan Usatiuk on 23.05.2023.
|
||||
//
|
||||
|
||||
#include "CommandListFiles.h"
|
||||
#include "../includes/CommandListFiles.h"
|
||||
|
||||
#include "../BytesFormatter.h"
|
||||
#include "../repo/Serialize.h"
|
||||
#include "../repo/objects/Archive.h"
|
||||
#include "../repo/objects/Chunk.h"
|
||||
#include "../repo/objects/File.h"
|
||||
#include "../../repo/includes/Serialize.h"
|
||||
#include "../../repo/includes/objects/Archive.h"
|
||||
#include "../../repo/includes/objects/Chunk.h"
|
||||
#include "../../repo/includes/objects/File.h"
|
||||
#include "../../utils/includes/BytesFormatter.h"
|
||||
|
||||
CommandListFiles::CommandListFiles() : Command("list-files") {
|
||||
}
|
||||
@@ -2,21 +2,21 @@
|
||||
// Created by Stepan Usatiuk on 23.05.2023.
|
||||
//
|
||||
|
||||
#include "CommandRestore.h"
|
||||
#include "../includes/CommandRestore.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include "../BytesFormatter.h"
|
||||
#include "../Exception.h"
|
||||
#include "../Progress.h"
|
||||
#include "../RunningDiffAverage.h"
|
||||
#include "../Signals.h"
|
||||
#include "../ThreadPool.h"
|
||||
#include "../chunkers/ChunkerFactory.h"
|
||||
#include "../repo/Serialize.h"
|
||||
#include "../repo/objects/Archive.h"
|
||||
#include "../repo/objects/Chunk.h"
|
||||
#include "../../chunkers/includes/ChunkerFactory.h"
|
||||
#include "../../repo/includes/Serialize.h"
|
||||
#include "../../repo/includes/objects/Archive.h"
|
||||
#include "../../repo/includes/objects/Chunk.h"
|
||||
#include "../../utils/includes/BytesFormatter.h"
|
||||
#include "../../utils/includes/Exception.h"
|
||||
#include "../../utils/includes/Progress.h"
|
||||
#include "../../utils/includes/RunningDiffAverage.h"
|
||||
#include "../../utils/includes/Signals.h"
|
||||
#include "../../utils/includes/ThreadPool.h"
|
||||
|
||||
using namespace CommandsCommon;
|
||||
|
||||
@@ -2,27 +2,27 @@
|
||||
// Created by Stepan Usatiuk on 23.05.2023.
|
||||
//
|
||||
|
||||
#include "CommandRun.h"
|
||||
#include "../includes/CommandRun.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
#include "../BytesFormatter.h"
|
||||
#include "../Exception.h"
|
||||
#include "../Progress.h"
|
||||
#include "../RunningDiffAverage.h"
|
||||
#include "../Signals.h"
|
||||
#include "../ThreadPool.h"
|
||||
#include "../change_detectors/ChangeDetectorFactory.h"
|
||||
#include "../chunkers/ChunkerFactory.h"
|
||||
#include "../crypto/MD5.h"
|
||||
#include "../repo/Serialize.h"
|
||||
#include "../repo/objects/Archive.h"
|
||||
#include "../repo/objects/Chunk.h"
|
||||
#include "../repo/objects/File.h"
|
||||
#include "../../change_detectors/includes/ChangeDetectorFactory.h"
|
||||
#include "../../chunkers/includes/ChunkerFactory.h"
|
||||
#include "../../crypto/includes/MD5.h"
|
||||
#include "../../repo/includes/Serialize.h"
|
||||
#include "../../repo/includes/objects/Archive.h"
|
||||
#include "../../repo/includes/objects/Chunk.h"
|
||||
#include "../../repo/includes/objects/File.h"
|
||||
#include "../../utils/includes/BytesFormatter.h"
|
||||
#include "../../utils/includes/Exception.h"
|
||||
#include "../../utils/includes/Progress.h"
|
||||
#include "../../utils/includes/RunningDiffAverage.h"
|
||||
#include "../../utils/includes/Signals.h"
|
||||
#include "../../utils/includes/ThreadPool.h"
|
||||
|
||||
#include "CommandsCommon.h"
|
||||
#include "../includes/CommandsCommon.h"
|
||||
|
||||
using namespace CommandsCommon;
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
// Created by Stepan Usatiuk on 23.05.2023.
|
||||
//
|
||||
|
||||
#include "CommandsCommon.h"
|
||||
#include "../includes/CommandsCommon.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <regex>
|
||||
|
||||
#include "../Exception.h"
|
||||
#include "../Signals.h"
|
||||
#include "../../utils/includes/Exception.h"
|
||||
#include "../../utils/includes/Signals.h"
|
||||
|
||||
void CommandsCommon::workerCallback(unsigned long long int bytesWritten, unsigned long long int bytesSkipped, unsigned long long int filesWritten, WorkerStats &to) {
|
||||
to.bytesWritten += bytesWritten;
|
||||
@@ -2,12 +2,12 @@
|
||||
// Created by Stepan Usatiuk on 06.05.2023.
|
||||
//
|
||||
|
||||
#include "Diff.h"
|
||||
#include "../includes/Diff.h"
|
||||
|
||||
#include "BytesFormatter.h"
|
||||
#include "Exception.h"
|
||||
#include "Signals.h"
|
||||
#include "chunkers/BuzhashChunker.h"
|
||||
#include "../../chunkers/includes/BuzhashChunker.h"
|
||||
#include "../../utils/includes/BytesFormatter.h"
|
||||
#include "../../utils/includes/Exception.h"
|
||||
#include "../../utils/includes/Signals.h"
|
||||
|
||||
bool Diff::isBinary(const ComparableFile &c) {
|
||||
auto b = c.contents();
|
||||
9
src/crypto/CMakeLists.txt
Normal file
9
src/crypto/CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
find_package(OpenSSL REQUIRED)
|
||||
|
||||
add_library(crypto srcs/AES.cpp srcs/CRC32.cpp srcs/MD5.cpp)
|
||||
|
||||
target_include_directories(crypto PUBLIC includes)
|
||||
|
||||
target_link_libraries(crypto OpenSSL::SSL utils)
|
||||
@@ -2,13 +2,13 @@
|
||||
// Created by Stepan Usatiuk on 30.04.2023.
|
||||
//
|
||||
|
||||
#include "AES.h"
|
||||
#include "../includes/AES.h"
|
||||
|
||||
#include <openssl/aes.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/rand.h>
|
||||
|
||||
#include "../Exception.h"
|
||||
#include "../../utils/includes/Exception.h"
|
||||
|
||||
std::vector<char> AES::encrypt(const std::vector<char> &in, const std::string &password, const std::string &salt) {
|
||||
return AES::encrypt(in, AES::deriveKey(password, salt));
|
||||
@@ -2,7 +2,7 @@
|
||||
// Created by Stepan Usatiuk on 12.05.2023.
|
||||
//
|
||||
|
||||
#include "CRC32.h"
|
||||
#include "../includes/CRC32.h"
|
||||
|
||||
CRC32::crcType CRC32::calculate(const std::vector<char> &in) {
|
||||
crcType res = crc32(0L, nullptr, 0);
|
||||
@@ -2,9 +2,9 @@
|
||||
// Created by Stepan Usatiuk on 15.04.2023.
|
||||
//
|
||||
|
||||
#include "MD5.h"
|
||||
#include "../includes/MD5.h"
|
||||
|
||||
#include "../Exception.h"
|
||||
#include "../../utils/includes/Exception.h"
|
||||
|
||||
std::string MD5::calculate(const std::vector<char> &in) {
|
||||
MD5 hasher;
|
||||
10
src/filters/CMakeLists.txt
Normal file
10
src/filters/CMakeLists.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
||||
add_library(filters srcs/CheckFilter.cpp srcs/Filter.cpp srcs/FilterAES.cpp srcs/FilterContainer.cpp srcs/FilterShift.cpp srcs/FilterShiftSecret.cpp srcs/FilterZlib.cpp srcs/FilterFactory.cpp)
|
||||
|
||||
target_include_directories(filters PUBLIC includes)
|
||||
|
||||
target_link_libraries(filters ZLIB::ZLIB utils)
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "../Config.h"
|
||||
#include "../../utils/includes/Config.h"
|
||||
#include "Filter.h"
|
||||
|
||||
/// Utility factory class for Filter%s
|
||||
@@ -1,7 +1,6 @@
|
||||
//
|
||||
// Created by Stepan Usatiuk on 22.04.2023.
|
||||
//
|
||||
#ifdef TEST
|
||||
#ifndef SEMBACKUP_FILTERSHIFT_H
|
||||
#define SEMBACKUP_FILTERSHIFT_H
|
||||
|
||||
@@ -27,4 +26,3 @@ private:
|
||||
|
||||
|
||||
#endif//SEMBACKUP_FILTERSHIFT_H
|
||||
#endif//TEST
|
||||
@@ -1,13 +1,11 @@
|
||||
//
|
||||
// Created by Stepan Usatiuk on 23.04.2023.
|
||||
//
|
||||
#ifdef TEST
|
||||
#ifndef SEMBACKUP_FILTERSHIFTSECRET_H
|
||||
#define SEMBACKUP_FILTERSHIFTSECRET_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Filter.h"
|
||||
#include <string>
|
||||
|
||||
/// Filter implementation that shifts every byte in input vector using two provided value
|
||||
/// \warning For testing purposes only!
|
||||
@@ -30,4 +28,3 @@ private:
|
||||
|
||||
|
||||
#endif//SEMBACKUP_FILTERSHIFTSECRET_H
|
||||
#endif//TEST
|
||||
@@ -2,9 +2,9 @@
|
||||
// Created by Stepan Usatiuk on 12.05.2023.
|
||||
//
|
||||
|
||||
#include "CheckFilter.h"
|
||||
#include "../crypto/CRC32.h"
|
||||
#include "../repo/Serialize.h"
|
||||
#include "../includes/CheckFilter.h"
|
||||
#include "../../crypto/includes/CRC32.h"
|
||||
#include "../../repo/includes/Serialize.h"
|
||||
|
||||
std::vector<char> CheckFilter::filterWrite(std::vector<char> from) const {
|
||||
return filterWriteStatic(std::move(from));
|
||||
@@ -2,5 +2,5 @@
|
||||
// Created by Stepan Usatiuk on 22.04.2023.
|
||||
//
|
||||
|
||||
#include "Filter.h"
|
||||
#include "../includes/Filter.h"
|
||||
Filter::~Filter() = default;
|
||||
@@ -2,9 +2,9 @@
|
||||
// Created by Stepan Usatiuk on 23.04.2023.
|
||||
//
|
||||
|
||||
#include "FilterAES.h"
|
||||
#include "../includes/FilterAES.h"
|
||||
|
||||
#include "../crypto/AES.h"
|
||||
#include "../../crypto/includes/AES.h"
|
||||
|
||||
std::vector<char> FilterAES::filterWrite(std::vector<char> from) const {
|
||||
return AES::encrypt(from, key);
|
||||
@@ -2,7 +2,7 @@
|
||||
// Created by Stepan Usatiuk on 22.04.2023.
|
||||
//
|
||||
|
||||
#include "FilterContainer.h"
|
||||
#include "../includes/FilterContainer.h"
|
||||
|
||||
FilterContainer::FilterContainer() = default;
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
// Created by Stepan Usatiuk on 22.04.2023.
|
||||
//
|
||||
|
||||
#include "FilterFactory.h"
|
||||
#include "../includes/FilterFactory.h"
|
||||
|
||||
#include "../Exception.h"
|
||||
#include "CheckFilter.h"
|
||||
#include "FilterAES.h"
|
||||
#include "FilterShift.h"
|
||||
#include "FilterShiftSecret.h"
|
||||
#include "FilterZlib.h"
|
||||
#include "../../utils/includes/Exception.h"
|
||||
#include "../includes/CheckFilter.h"
|
||||
#include "../includes/FilterAES.h"
|
||||
#include "../includes/FilterShift.h"
|
||||
#include "../includes/FilterShiftSecret.h"
|
||||
#include "../includes/FilterZlib.h"
|
||||
|
||||
std::unique_ptr<Filter> FilterFactory::makeFilter(const std::string &type, const Config &config) {
|
||||
if (type == "none") throw Exception("Trying to make a \"none\" filter!");
|
||||
@@ -20,13 +20,10 @@ std::unique_ptr<Filter> FilterFactory::makeFilter(const std::string &type, const
|
||||
return std::make_unique<FilterZlib>(config.getInt("compression-level"));
|
||||
} else if (type == "crc") {
|
||||
return std::make_unique<CheckFilter>();
|
||||
}
|
||||
#ifdef TEST
|
||||
else if (type == "shiftC") {
|
||||
} else if (type == "shiftC") {
|
||||
return std::make_unique<FilterShift>(config.getInt("compression-level"));
|
||||
} else if (type == "shiftE")
|
||||
return std::make_unique<FilterShiftSecret>(config.getStr("password"), config.getStr("salt"));
|
||||
#endif
|
||||
|
||||
throw Exception("Unknown filter value");
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
//
|
||||
// Created by Stepan Usatiuk on 22.04.2023.
|
||||
//
|
||||
#ifdef TEST
|
||||
#include "FilterShift.h"
|
||||
#include "../includes/FilterShift.h"
|
||||
|
||||
std::vector<char> FilterShift::filterWrite(std::vector<char> from) const {
|
||||
for (auto &c: from) c += shiftVal;
|
||||
@@ -15,4 +14,3 @@ std::vector<char> FilterShift::filterRead(std::vector<char> from) const {
|
||||
}
|
||||
|
||||
FilterShift::FilterShift(int level) : shiftVal(level) {}
|
||||
#endif
|
||||
@@ -1,9 +1,8 @@
|
||||
//
|
||||
// Created by Stepan Usatiuk on 23.04.2023.
|
||||
//
|
||||
#ifdef TEST
|
||||
|
||||
#include "FilterShiftSecret.h"
|
||||
#include "../includes/FilterShiftSecret.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -20,4 +19,3 @@ std::vector<char> FilterShiftSecret::filterRead(std::vector<char> from) const {
|
||||
FilterShiftSecret::FilterShiftSecret(const std::string &password, const std::string &salt) {
|
||||
shiftVal = password[0] + salt[0];
|
||||
}
|
||||
#endif
|
||||
@@ -2,11 +2,11 @@
|
||||
// Created by Stepan Usatiuk on 23.04.2023.
|
||||
//
|
||||
|
||||
#include "FilterZlib.h"
|
||||
#include "../includes/FilterZlib.h"
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
#include "../repo/Serialize.h"
|
||||
#include "../../repo/includes/Serialize.h"
|
||||
|
||||
std::vector<char> FilterZlib::filterWrite(std::vector<char> from) const {
|
||||
uLongf outSize = compressBound(from.size());
|
||||
34
src/main.cpp
34
src/main.cpp
@@ -1,23 +1,23 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "BytesFormatter.h"
|
||||
#include "Config.h"
|
||||
#include "Context.h"
|
||||
#include "Exception.h"
|
||||
#include "Logger.h"
|
||||
#include "Signals.h"
|
||||
#include "commands/Command.h"
|
||||
#include "commands/CommandDiff.h"
|
||||
#include "commands/CommandList.h"
|
||||
#include "commands/CommandListFiles.h"
|
||||
#include "commands/CommandRestore.h"
|
||||
#include "commands/CommandRun.h"
|
||||
#include "repo/FileRepository.h"
|
||||
#include "repo/Repository.h"
|
||||
#include "repo/Serialize.h"
|
||||
#include "repo/objects/Archive.h"
|
||||
#include "repo/objects/File.h"
|
||||
#include "commands/includes/Command.h"
|
||||
#include "commands/includes/CommandDiff.h"
|
||||
#include "commands/includes/CommandList.h"
|
||||
#include "commands/includes/CommandListFiles.h"
|
||||
#include "commands/includes/CommandRestore.h"
|
||||
#include "commands/includes/CommandRun.h"
|
||||
#include "commands/includes/Context.h"
|
||||
#include "repo/includes/FileRepository.h"
|
||||
#include "repo/includes/Repository.h"
|
||||
#include "repo/includes/Serialize.h"
|
||||
#include "repo/includes/objects/Archive.h"
|
||||
#include "repo/includes/objects/File.h"
|
||||
#include "utils/includes/BytesFormatter.h"
|
||||
#include "utils/includes/Config.h"
|
||||
#include "utils/includes/Exception.h"
|
||||
#include "utils/includes/Logger.h"
|
||||
#include "utils/includes/Signals.h"
|
||||
|
||||
Config getConf(int argc, char *argv[]) {
|
||||
Config out;
|
||||
|
||||
7
src/repo/CMakeLists.txt
Normal file
7
src/repo/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
add_library(repo srcs/FileRepository.cpp srcs/Object.cpp srcs/Repository.cpp srcs/objects/Archive.cpp srcs/objects/Chunk.cpp srcs/objects/File.cpp srcs/objects/FileBuffer.cpp)
|
||||
|
||||
target_include_directories(repo PUBLIC includes)
|
||||
|
||||
target_link_libraries(repo filters)
|
||||
@@ -9,8 +9,8 @@
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
|
||||
#include "../Config.h"
|
||||
#include "../filters/FilterContainer.h"
|
||||
#include "../../filters/includes/FilterContainer.h"
|
||||
#include "../../utils/includes/Config.h"
|
||||
#include "Object.h"
|
||||
|
||||
/// Abstract base class for an Object Repository
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <endian.h>
|
||||
#endif
|
||||
|
||||
#include "../Exception.h"
|
||||
#include "../../utils/includes/Exception.h"
|
||||
|
||||
/// Serialization library
|
||||
/**
|
||||
@@ -2,16 +2,16 @@
|
||||
// Created by Stepan Usatiuk on 14.04.2023.
|
||||
//
|
||||
|
||||
#include "FileRepository.h"
|
||||
#include "../includes/FileRepository.h"
|
||||
|
||||
#include <exception>
|
||||
#include <iterator>
|
||||
#include <mutex>
|
||||
|
||||
#include "../filters/CheckFilter.h"
|
||||
#include "../filters/FilterFactory.h"
|
||||
#include "Object.h"
|
||||
#include "Serialize.h"
|
||||
#include "../../filters/includes/CheckFilter.h"
|
||||
#include "../../filters/includes/FilterFactory.h"
|
||||
#include "../includes/Object.h"
|
||||
#include "../includes/Serialize.h"
|
||||
|
||||
FileRepository::FileRepository(Config config) : Repository(std::move(config)), root(std::filesystem::path(this->config.getStr("repo"))), writeCacheMax(config.getInt("repo-target") * 1024 * 1024) {}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
// Created by Stepan Usatiuk on 14.04.2023.
|
||||
//
|
||||
|
||||
#include "Object.h"
|
||||
#include "../includes/Object.h"
|
||||
|
||||
#include "Serialize.h"
|
||||
#include "../includes/Serialize.h"
|
||||
|
||||
Object::Object(idType id, ObjectType type) : id(id), type(type) {}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Created by Stepan Usatiuk on 14.04.2023.
|
||||
//
|
||||
|
||||
#include "Repository.h"
|
||||
#include "../includes/Repository.h"
|
||||
Repository::~Repository() = default;
|
||||
|
||||
Repository::Repository(Config config) : config(std::move(config)) {}
|
||||
@@ -2,10 +2,10 @@
|
||||
// Created by Stepan Usatiuk on 14.04.2023.
|
||||
//
|
||||
|
||||
#include "Archive.h"
|
||||
#include "../../includes/objects/Archive.h"
|
||||
|
||||
#include "../../Exception.h"
|
||||
#include "../Serialize.h"
|
||||
#include "../../../utils/includes/Exception.h"
|
||||
#include "../../includes/Serialize.h"
|
||||
|
||||
Archive::Archive(Object::idType id, std::string name, unsigned long long mtime, std::vector<idType> files, bool full)
|
||||
: Object(id, ObjectType::Archive), name(name), mtime(mtime), files(files), isFull(full) {}
|
||||
@@ -2,10 +2,10 @@
|
||||
// Created by Stepan Usatiuk on 14.04.2023.
|
||||
//
|
||||
|
||||
#include "Chunk.h"
|
||||
#include "../../includes/objects/Chunk.h"
|
||||
|
||||
#include "../../Exception.h"
|
||||
#include "../Serialize.h"
|
||||
#include "../../../utils/includes/Exception.h"
|
||||
#include "../../includes/Serialize.h"
|
||||
|
||||
Chunk::Chunk(idType id, std::string md5, std::vector<char> data) : Object(id, ObjectType::Chunk), data(std::move(data)), md5(std::move(md5)), length(this->data.size()) {}
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
// Created by Stepan Usatiuk on 14.04.2023.
|
||||
//
|
||||
|
||||
#include "File.h"
|
||||
#include "../../includes/objects/File.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../../Exception.h"
|
||||
#include "../Serialize.h"
|
||||
#include "../../../utils/includes/Exception.h"
|
||||
#include "../../includes/Serialize.h"
|
||||
|
||||
File::File(Object::idType id, std::string name, unsigned long long bytes, unsigned long long mtime, std::string md5, std::vector<idType> chunks, Type fileType)
|
||||
: Object(id, ObjectType::File), name(name), bytes(bytes), mtime(mtime), md5(md5), fileType(fileType), chunks(chunks) {}
|
||||
@@ -2,9 +2,9 @@
|
||||
// Created by Stepan Usatiuk on 23.04.2023.
|
||||
//
|
||||
|
||||
#include "FileBuffer.h"
|
||||
#include "../../includes/objects/FileBuffer.h"
|
||||
|
||||
#include "../Serialize.h"
|
||||
#include "../../includes/Serialize.h"
|
||||
|
||||
FileBuffer::FileBuffer(const Repository *repo, Object::idType fileId) : repo(repo), file(Serialize::deserialize<File>(repo->getObject(fileId))), chunksQueue() {
|
||||
for (auto const &id: file.chunks) chunksQueue.emplace(id);
|
||||
5
src/utils/CMakeLists.txt
Normal file
5
src/utils/CMakeLists.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
add_library(utils srcs/BytesFormatter.cpp srcs/Config.cpp srcs/Exception.cpp srcs/Logger.cpp srcs/Progress.cpp srcs/RunningAverage.cpp srcs/RunningDiffAverage.cpp srcs/Signals.cpp srcs/ThreadPool.cpp)
|
||||
|
||||
target_include_directories(utils PUBLIC includes)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user