OdbDesign
OdbDesign ODB++ Parser - C++ library, gRPC/REST server, CLI, tests
 
Loading...
Searching...
No Matches
ArchiveExtractor.h
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <filesystem>
5#include "utils_export.h"
7#include <vector>
8
9
10namespace Utils
11{
13 {
14 public:
15
16 enum class e7zExitCode
17 {
18 Success = 0,
19 Warning = 1,
20 FatalError = 2,
21 CommandLineError = 7,
22 NotEnoughMemory = 8,
23 UserStopped = 255
24 };
25
26 ArchiveExtractor(const std::string& path, bool bExtractLzmaInProc = false, bool bExtractLzmaUsing7Zip = true);
27 //~ArchiveExtractor();
28
29 std::filesystem::path GetPath() const;
30 std::string GetExtractionDirectory() const;
31
32 static bool IsArchiveTypeSupported(const std::filesystem::path& file);
33 static bool IsArchiveTypeSupported(const std::string& file);
34
35 bool Extract();
36 bool Extract(const std::string& destinationPath);
37
38 static std::filesystem::path getUncompressedFilePath(const std::filesystem::path& directory, const std::string& filename);
39
40 static bool CompressDir(const std::string& srcDir, const std::string& destDir,
41 const std::string& archiveName, std::string& fileOut,
42 CompressionType type = CompressionType::TarGzip);
43
44 constexpr static inline bool ALLOW_ALL_ARCHIVE_EXTENSION_TYPES = false;
45 constexpr static inline const char* SupportedExtensions[] = { "tgz", "tar.gz", "gz", "zip", "Z", "gzip", "tar" };
46
47 private:
48 std::filesystem::path m_path;
49 std::string m_extractionDirectory;
50 bool m_bExtractLzmaInProc = false;
51 bool m_bExtractLzmaUsing7Zip = true;
52
53 bool ExtractLzmaOutOfProc(const std::filesystem::path& destinationPath);
54 bool ExtractLzmaInProc(const std::filesystem::path& destinationPath);
55
56 static inline const std::vector<std::string> LZMA_FILE_EXTENSIONS = { ".Z", ".z", ".lzma", ".lz" };
57
58 };
59}
static bool IsArchiveTypeSupported(const std::filesystem::path &file)
#define UTILS_EXPORT