-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define and expose user-defined error handler #156
Define and expose user-defined error handler #156
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@flomnes Thanks for the PR ! I left a few comments. Can you also rebase, since there is a conflict.
src/libzippp.h
Outdated
@@ -538,6 +547,8 @@ namespace libzippp { | |||
|
|||
void** bufferData; | |||
libzippp_uint64 bufferLength; | |||
|
|||
ErrorHandlerCallback errorHandlingCallback = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initialize the variable in the constructor initializer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -526,6 +531,10 @@ namespace libzippp { | |||
inline double getProgressPrecision(void) const { return progressPrecision; } | |||
void setProgressPrecision(double p) { progressPrecision = p; } | |||
|
|||
void setErrorHandlerCallback(const ErrorHandlerCallback& callback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, see README.md
@@ -99,14 +99,19 @@ struct zip_source; | |||
namespace libzippp { | |||
class ZipEntry; | |||
class ZipProgressListener; | |||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an empty line before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
/** | ||
* Represents a ZIP archive. This class provides useful methods to handle an archive | ||
* content. It is simply a wrapper around libzip. | ||
*/ | ||
class LIBZIPPP_API ZipArchive { | ||
public: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please let this empty line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/libzippp.cpp
Outdated
@@ -310,7 +330,11 @@ int ZipArchive::close(void) { | |||
zip_int64_t newLength = bufferLength + increment; | |||
sourceBuffer = realloc(sourceBuffer, newLength * sizeof(char)); | |||
if(sourceBuffer==nullptr) { | |||
if (errorHandlingCallback) { | |||
callErrorHandlingCb(zipHandle, errorHandlingCallback); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beware of the indentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Co-authored-by: Cédric Tabin <tabin.cedric@gmail.com>
85351c4
to
6a6268f
Compare
@flomnes LGTM. Thanks for the amazing work ! |
No description provided.