From a7e8189d38751fb7cc149373d382c1ee76d0bf49 Mon Sep 17 00:00:00 2001 From: avinal <185067@nith.ac.in> Date: Fri, 5 Mar 2021 01:41:13 +0530 Subject: [PATCH] blowfish cmake change --- CMakeLists.txt | 5 ++-- include/Utils.hpp | 65 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 include/Utils.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 99b4042..fdffa0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,8 +10,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(SQLITECPP_RUN_CPPCHECK OFF CACHE BOOL "" FORCE) set(SQLITECPP_RUN_CPPLINT OFF CACHE BOOL "" FORCE) - -add_subdirectory(blowfish) +if(NOT TARGET libblowfish) + add_subdirectory(blowfish) +endif() add_executable(${PROJECT_NAME} ${SOURCES}) diff --git a/include/Utils.hpp b/include/Utils.hpp new file mode 100644 index 0000000..ad46722 --- /dev/null +++ b/include/Utils.hpp @@ -0,0 +1,65 @@ +/** + * /mnt/z/my_git/RCRS-CSD-327/include/Utils.hpp + * @file Utils.hpp + * @author Avinal Kumar + * @since March 04, 2021 + * + * Utilities + */ +// include blowfish library +#include + +// include standard headers +#include +#include +#include +#include +#include + +// defines +namespace fs = std::filesystem; + +#if !defined(UTILS_HPP) +#define UTILS_HPP + +namespace MCPS { + +struct filestat { + std::string filename; + fs::path filepath; + DWORD filesize; + fs::file_type filetype; + std::time_t m_time; + bool is_regular; + + filestat(std::string const &file_name); + void print(); + +private: + template std::time_t to_time_t(TP tp) { + using namespace std::chrono; + auto sctp = time_point_cast(tp - TP::clock::now() + + system_clock::now()); + return system_clock::to_time_t(sctp); + } +}; + +class fileop { +private: + std::unordered_map _files; + +public: + DWORD read_file(std::string const &infile, std::vector &input_buf, + filestat const &stat); + + DWORD write_file(std::string const &outfile, std::vector &output_buf, + DWORD out_size); + std::unordered_map scan_current_directory(); + DWORD pad_input(std::vector &input_buf, DWORD in_size); + DWORD attch_key(std::vector &input_buf, std::string const &key, + DWORD in_size); +}; + +} // namespace MCPS + +#endif // UTILS_HPP