BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnCompressionGlobalFunctions.h
Go to the documentation of this file.
1#pragma once
2#ifndef BmnCompressionGlobalFunctions_h
3#define BmnCompressionGlobalFunctions_h
4
5// headers from this target
7#include "BmnIFileReader.h"
8// std: headers
9#include <filesystem>
10#include <string_view>
11
12/*
13 * The extensions of the archive formats which the file readers of this target are able to open
14 * The extensions are written in the lower case, because they are compared case-insensitively
15 */
16inline constexpr std::string_view BmnCompressionArchiveExtensions[]{".zst", ".zstd", ".gz", ".gzip", ".xz", ".lzma"};
17
18/*
19 * A method to check whether a specific archive library was loaded (found) while building binaries.
20 * If the library was found, it's safe to use it, otherwise, some unexpected throws might appear.
21 * @param aLibraryType A library type one wants to check and use
22 * @return 'true' if the archive library is supported, or 'false' if not
23 */
24[[nodiscard]] bool BmnCompressionIsArchiveLibAvailable(const BmnFileType aLibraryType) noexcept;
25
26/*
27 * A function that selects and creates an appropriate reader-class instance based on magic bytes of
28 * the provided file. If no familiar magic bytes are found, the fill will be opened for raw-binary reading
29 * @param aFilePath A path to an existing, actual and accessible file that should be read
30 * @param aPreferredTypeForThisAlgorithm With this, one can choose which processing library to use if there
31 * are multiple libraries using the same algorithm. For instance, ZLib and ZLib-ng use the same Deflate algorithm
32 * @return A selected appropriate file reader. The returned instance should be freed (deleted) by the caller!
33 */
35 const std::filesystem::path& aFilePath,
36 const BmnFileType aPreferredTypeForThisAlgorithm = BmnFileType::Unknown);
37
38/*
39 * A function that selects and creates an appropriate reader-class instance based on magic bytes of
40 * the provided file. If no familiar magic bytes are found, the fill will be opened for raw-binary reading
41 * @param aFilePath A path to an existing, actual and accessible file that should be read
42 * @param aPreferredTypeForThisAlgorithm With this, one can choose which processing library to use if there
43 * are multiple libraries using the same algorithm. For instance, ZLib and ZLib-ng use the same Deflate algorithm
44 * @return A selected appropriate file reader. The returned instance should be freed (deleted) by the caller!
45 */
47 std::filesystem::path&& aFilePath,
48 const BmnFileType aPreferredTypeForThisAlgorithm = BmnFileType::Unknown);
49
50/*
51 * A function that drops the trailing archive extension of a path, if there is one
52 * Only the extension is analysed here, the file itself is neither opened nor required to exist
53 * @param aFilePath A path (or a file name) which can end with an archive extension
54 * @return The path without the trailing archive extension, or the very same path if it has no such extension
55 */
56[[nodiscard]] std::filesystem::path BmnCompressionRemoveArchiveExtension(std::filesystem::path aFilePath);
57
58#endif // BmnCompressionGlobalFunctions_h
constexpr std::string_view BmnCompressionArchiveExtensions[]
bool BmnCompressionIsArchiveLibAvailable(const BmnFileType aLibraryType) noexcept
BmnIFileReader * BmnCompressionCreateNewSuitableReaderForAFile(const std::filesystem::path &aFilePath, const BmnFileType aPreferredTypeForThisAlgorithm=BmnFileType::Unknown)
std::filesystem::path BmnCompressionRemoveArchiveExtension(std::filesystem::path aFilePath)