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;
const ArgumentContainer & arguments() const
Get program arguments.
ArgumentParser & parser()
Get program arguments parser.
const Vector< Argument * > & getPositionals() const
Get positional arguments.
void setDescription(const String &desc)
Set program description.
Result registerPositional(const char *name, const char *description, Size count=1)
Register a positional argument.
Provides a buffered abstract interface to a file.
const Size size() const
Get file size.
Result read()
Read the file (buffered)
const char * path() const
Get file path.
const void * buffer() const
Get file buffer.
Result decompressFile(const String inputFilename) const
Decompress the given file.
virtual Result exec()
Execute the application.
virtual ~Decompress()
Destructor.
Decompress(int argc, char **argv)
Constructor.
Decompress data using the LZ4 algorithm created by Yann Collet.
Result initialize()
Initialize the decompressor.
u64 getUncompressedSize() const
Get size of the uncompressed data.
Result read(void *buffer, const Size size) const
Reads compressed data.
POSIX-compatible application.
virtual Result output(const char *string) const
Print text to output.
String substring(const Size index, const Size size=0) const
Returns a part of the String as a copy.
Size length() const
Same as count().
bool endsWith(const String &suffix) const
Tests if this String ends with the specified suffix.
Vectors are dynamically resizeable Arrays.
virtual Size count() const
Returns the number of items inside the Vector.
#define ERROR(msg)
Output an error message.
unsigned int Size
Any sane size indicator cannot go negative.
#define DEBUG(msg)
Output a debug message to standard output.
unsigned char u8
Unsigned 8-bit number.