Giter Site home page Giter Site logo

Comments (2)

rikyoz avatar rikyoz commented on May 18, 2024

You're welcome, and thank you for using it! I'm planning to add callback API in the next version 2.1.x. I hope to release it by the end of May.

from bit7z.

rikyoz avatar rikyoz commented on May 18, 2024

I've implemented the API for callbacks, it is available in the develop branch (see class BitArchiveHandler, which now is the base class for every compressor and extractor class).
Supported callbacks are:

  • Total callback (signature: void( uint64_t )), whose argument is the total size of the archive to be extracted or of the files to be compressed (it is called at the beginning of any operation).
  • Progress callback (signature: void( uint64_t )), whose argument is the current processed size; calculating the ratio between the processed size and the total size (given by the total callback) gives the current operation progress (e.g. static_cast<int>( ( 100.0 * completed ) / total ))
  • Ratio callback (signature: void( uint64_t, uint64_t )), in which the two arguments are, respectively, the input size and output size (e.g. compression ratio can be calculated as static_cast<int>( ( 100.0 * out_size ) / in_size )).
  • File callback (signature: void( wstring )), whose argument is the name of the file currently being processed.
  • Password callback (signature: wstring()), which is called when a password was not specified in code (e.g. through setPassword method) but it is needed in order to open and/or extract the archive; the callback must return a wstring containing the password entered by the user.

Callbacks are stored as std::functions, hence callbacks can be lambdas, free functions, member functions, etc...

Obviously I'm open to any suggestion of improvement of the API!

from bit7z.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.