Go to the documentation of this file.
39 for (
Size i = 0; i < positionals.
count(); i++)
56 const char *lz4Extension =
".lz4";
58 DEBUG(
"file = " << *inputFilename);
61 if (!inputFilename.
endsWith(lz4Extension))
63 ERROR(
"input file name does not end with " << lz4Extension);
68 const String outputFilename =
78 ERROR(
"failed to read input file " << input.
path());
87 ERROR(
"failed to initialize LZ4 decompressor: result = " << (
int) result);
93 u8 *uncompressed =
new u8[originalSize];
99 ERROR(
"failed to decompress file " << *inputFilename <<
": result = " << (
int) readResult);
100 delete[] uncompressed;
108 ERROR(
"failed to write output file " << *outputFilename <<
": result = " << (
int) writeResult);
109 delete[] uncompressed;
114 delete[] uncompressed;
virtual Result output(const char *string) const
Print text to output.
Provides a buffered abstract interface to a file.
Size length() const
Same as count().
Decompress(int argc, char **argv)
Constructor.
u64 getUncompressedSize() const
Get size of the uncompressed data.
Result decompressFile(const String inputFilename) const
Decompress the given file.
virtual ~Decompress()
Destructor.
Result initialize()
Initialize the decompressor.
POSIX-compatible application.
virtual Result exec()
Execute the application.
const ArgumentContainer & arguments() const
Get program arguments.
void setDescription(const String &desc)
Set program description.
const void * buffer() const
Get file buffer.
Result read()
Read the file (buffered)
#define DEBUG(msg)
Output a debug message to standard output.
virtual Size count() const
Returns the number of items inside the Vector.
unsigned int Size
Any sane size indicator cannot go negative.
String substring(const Size index, const Size size=0) const
Returns a part of the String as a copy.
Result registerPositional(const char *name, const char *description, Size count=1)
Register a positional argument.
ArgumentParser & parser()
Get program arguments parser.
const Size size() const
Get file size.
Result read(void *buffer, const Size size) const
Reads compressed data.
#define ERROR(msg)
Output an error message.
unsigned char u8
Unsigned 8-bit number.
Decompress data using the LZ4 algorithm created by Yann Collet.
bool endsWith(const String &suffix) const
Tests if this String ends with the specified suffix.
const Vector< Argument * > & getPositionals() const
Get positional arguments.
const char * path() const
Get file path.