libxcks
0.1.0.1
|
A XCKS file writer. More...
#include <xcksfilewriter.hpp>
Public Member Functions | |
XCKSFileWriter (XCKSWriterHandler &xcksWriterHandler, XCKSWriterChecksumProvider &checksumProvider, const XCKSWriterOptions &options, const std::filesystem::path &baseDir, const ArrayChecksumAlgoId &algoIds, const ChecksumFormatter::ConfigurationProvider &confProvider, Version version=Version::Last_Valid) | |
Constructor. More... | |
XCKSFileWriter (const XCKSFileWriter &source)=delete | |
Deleted copy constructor. More... | |
XCKSFileWriter & | operator= (const XCKSFileWriter &source)=delete |
Deleted assignment operator. More... | |
~XCKSFileWriter () | |
Destructor. More... | |
StringSet | getAvailableChecksumTypesName () const |
Returns the list of names of available checksums algorithms for this particular version of XCKS file. More... | |
ArrayChecksumAlgoId | getAvailableChecksumTypes () const |
Returns the list of available checksums algorithms for this type of checksums' file. More... | |
ArrayChecksumAlgoId | getChecksumTypesForNewEntries () const |
Returns the list of checksums algorithms to compute for new entries of this type of checksums' file. More... | |
Version | getVersion () const |
Returns the version of the checksums' file type. More... | |
void | getVersion (unsigned int &major, unsigned int &minor, unsigned int &revision) const |
Gets the version of the checksums' file type. More... | |
std::string | getStrVersion () const |
Gets the version of the checksums' file type as a string. More... | |
bool | write (std::ostream &os, const ArrayPath &relativePaths) |
Writes the checksums in a stream. More... | |
Protected Member Functions | |
ArrayChecksumAlgoId | getValidChecksumTypesForNewEntries (const ArrayChecksumAlgoId &ids) const |
Gets a valid list of algorithms to calculate for each file. More... | |
XCKSWriterChecksumProvider::Status | getChecksumValues (ArrayChecksumValue &ckValues, uintmax_t &filesize, time_t &filedatetime, const ArrayChecksumAlgoId &ids, const std::filesystem::path &filePath, bool &stopWriting) const |
Gets checksums values from an array of wanted algorithms of checksums. More... | |
bool | writeLocalFilesV1 (std::ostream &os, const ArrayPath &relativePaths, int &indent) |
Writes the "localFiles" section of a XCKS file version 1.0.0 in a stream. More... | |
bool | writeV1 (std::ostream &os, const ArrayPath &relativePaths) |
Writes the XCKS file version 1.0.0 in a stream. More... | |
bool | writeLine (std::ostream &os, const std::string &line, const int indent) |
Writes a line in the XCKS file. More... | |
bool | getXCKSAlgorithmName (std::string &algoName, const ChecksumAlgoId algoId) |
Gets the algorithm name in the XCKS specification. More... | |
Static Protected Member Functions | |
static Version | getValidVersion (const Version ver) |
Ensures a valid version of XCKS file. More... | |
Protected Attributes | |
XCKSWriterHandler & | writerHandler |
The XCKS file writer handler. More... | |
XCKSWriterChecksumProvider & | ckProvider |
The provider of checksums values. More... | |
const XCKSWriterOptions & | writerOptions |
The writer options. More... | |
const std::filesystem::path | baseDirectory |
The base directory of the checksums' file. More... | |
const Version | version |
Version of the (Z)XCKS file to write. More... | |
const StringSet | possibleSumsAlgos |
Possible algorithms names for a (Z)XCKS file. More... | |
const ArrayChecksumAlgoId | sumsAlgos |
Type of algorithms' checksums to write for each file. More... | |
const ChecksumFormatter::ConfigurationProvider & | ckfConfProvider |
Configuration provider for ChecksumFormatter . More... | |
Static Protected Attributes | |
static const std::string | parentDir = ".." |
Parent directory on Unix and windows. More... | |
A XCKS file writer.
Definition at line 41 of file xcksfilewriter.hpp.
libxcks::XCKSFileWriter::XCKSFileWriter | ( | XCKSWriterHandler & | xcksWriterHandler, |
XCKSWriterChecksumProvider & | checksumProvider, | ||
const XCKSWriterOptions & | options, | ||
const std::filesystem::path & | baseDir, | ||
const ArrayChecksumAlgoId & | algoIds, | ||
const ChecksumFormatter::ConfigurationProvider & | confProvider, | ||
Version | version = Version::Last_Valid |
||
) |
Constructor.
xcksWriterHandler | The XCKS file reader handler. |
checksumProvider | The provider of checksums values from an array of of wanted algorithms of checksums. |
options | Options of the XCKS writer. |
baseDir | The base directory of the (Z)XCKS file to read. Must be an absolute path name. |
algoIds | The algorithms to compute for each file. Each algorithm must appears only once in the array. |
confProvider | Configuration provider for ChecksumFormatter . |
version | The wanted version of XCKS specification file. |
Definition at line 934 of file xcksfilewriter.cpp.
|
delete |
Deleted copy constructor.
libxcks::XCKSFileWriter::~XCKSFileWriter | ( | ) |
Destructor.
Definition at line 960 of file xcksfilewriter.cpp.
ArrayChecksumAlgoId libxcks::XCKSFileWriter::getAvailableChecksumTypes | ( | ) | const |
Returns the list of available checksums algorithms for this type of checksums' file.
Definition at line 990 of file xcksfilewriter.cpp.
StringSet libxcks::XCKSFileWriter::getAvailableChecksumTypesName | ( | ) | const |
Returns the list of names of available checksums algorithms for this particular version of XCKS file.
Definition at line 976 of file xcksfilewriter.cpp.
ArrayChecksumAlgoId libxcks::XCKSFileWriter::getChecksumTypesForNewEntries | ( | ) | const |
Returns the list of checksums algorithms to compute for new entries of this type of checksums' file.
Must be equal or a subgroup of getAvailableChecksumTypes().
Definition at line 1016 of file xcksfilewriter.cpp.
|
protected |
Gets checksums values from an array of wanted algorithms of checksums.
When returning sumValues
must contains the checksums values required in ids
, in any order, but no less and no more.
[out] | ckValues | The calculated values. |
[out] | filesize | The size of path . Can be Invalid_File_Size . |
[out] | filedatetime | The date/time of path . Can be Invalid_DateTime . |
[in] | ids | The ids of the wanted algorithm of checksums. |
[in] | filePath | Relative path to baseDirectory of the file from which the checksums must be calculated. |
[out] | stopWriting | Should the writing of the XCKS must be stopped on error? Must be set to true to stop the writing. |
true
if the file has been successfully read and the required checksums has been successfully calculated and provided, false
otherwise. Definition at line 1190 of file xcksfilewriter.cpp.
string libxcks::XCKSFileWriter::getStrVersion | ( | ) | const |
Gets the version of the checksums' file type as a string.
Definition at line 1061 of file xcksfilewriter.cpp.
|
protected |
Gets a valid list of algorithms to calculate for each file.
[in] | ids | The ids of the wanted algorithm of checksums to validate. |
Definition at line 1130 of file xcksfilewriter.cpp.
Ensures a valid version of XCKS file.
[in] | ver | The version to check. |
Definition at line 1115 of file xcksfilewriter.cpp.
Version libxcks::XCKSFileWriter::getVersion | ( | ) | const |
Returns the version of the checksums' file type.
Definition at line 1028 of file xcksfilewriter.cpp.
void libxcks::XCKSFileWriter::getVersion | ( | unsigned int & | major, |
unsigned int & | minor, | ||
unsigned int & | revision | ||
) | const |
Gets the version of the checksums' file type.
[out] | major | Major version of the XCKS file. |
[out] | minor | Minor version of the XCKS file. |
[out] | revision | Revision of the XCKS file. |
Definition at line 1042 of file xcksfilewriter.cpp.
|
protected |
Gets the algorithm name in the XCKS specification.
[out] | algoName | The algorithm's name. |
[in] | algoId | The algorithm's identifier. |
true
if the algorithm's identifier is a valid algorithm for the XCKS file, false
otherwise. Definition at line 1566 of file xcksfilewriter.cpp.
|
delete |
Deleted assignment operator.
bool libxcks::XCKSFileWriter::write | ( | std::ostream & | os, |
const ArrayPath & | relativePaths | ||
) |
Writes the checksums in a stream.
After the writing of the stream, the state of the file should be unmodified and the file name must be modified to fileName
. The paths of the files in SumFile::entries
must be relative to the path of SumFile::fileName
.
os | The output stream in which the checksums are written. |
relativePaths | Relative paths (from baseDir ) of files to add in the XCKS file. |
true
if the checksums have been written successfully, false
otherwise. Definition at line 1084 of file xcksfilewriter.cpp.
|
protected |
Writes a line in the XCKS file.
The line is written with the parameters defined for this XCKS file (compact or not, type of indentation).
os | The output stream in which the line is written. |
line | The line to write. |
indent | The level of indentation, must be greater or equal to 0 . |
Definition at line 1537 of file xcksfilewriter.cpp.
|
protected |
Writes the "localFiles" section of a XCKS file version 1.0.0 in a stream.
[in,out] | os | The output stream in which the checksums are written. |
[in] | relativePaths | Relative paths (from baseDir ) of files to add in the XCKS file. |
[in,out] | indent | The current indentation level in XML structure. |
true
if the checksums' file have been written successfully, false
otherwise. Definition at line 1297 of file xcksfilewriter.cpp.
|
protected |
Writes the XCKS file version 1.0.0 in a stream.
os | The output stream in which the checksums are written. |
relativePaths | Relative paths (from baseDir ) of files to add in the XCKS file. |
true
if the checksums' file have been written successfully, false
otherwise. Definition at line 1446 of file xcksfilewriter.cpp.
|
protected |
The base directory of the checksums' file.
Definition at line 47 of file xcksfilewriter.hpp.
|
protected |
Configuration provider for ChecksumFormatter
.
Definition at line 51 of file xcksfilewriter.hpp.
|
protected |
The provider of checksums values.
Definition at line 45 of file xcksfilewriter.hpp.
|
staticprotected |
Parent directory on Unix and windows.
Definition at line 53 of file xcksfilewriter.hpp.
|
protected |
Possible algorithms names for a (Z)XCKS file.
Definition at line 49 of file xcksfilewriter.hpp.
|
protected |
Type of algorithms' checksums to write for each file.
Definition at line 50 of file xcksfilewriter.hpp.
|
protected |
Version of the (Z)XCKS file to write.
Definition at line 48 of file xcksfilewriter.hpp.
|
protected |
The XCKS file writer handler.
Definition at line 44 of file xcksfilewriter.hpp.
|
protected |
The writer options.
Definition at line 46 of file xcksfilewriter.hpp.