Note that there are some explanatory texts on larger screens.

plurals
  1. POStack overflow creating an archive using libzip
    primarykey
    data
    text
    <p>To get started with <a href="http://www.nih.at/libzip/index.html" rel="nofollow">libzip</a>, I tried to create an archive and add a file to it. This is my code.</p> <pre><code>string archive = "path/to/archive.zip"; string file = "message"; char *data = "Hello World!"; int error = 0; zip *archive = zip_open(path.c_str(), ZIP_CREATE, &amp;error); if(error) { cout &lt;&lt; "could not open or create archive" &lt;&lt; endl; return false; } zip_source *source = zip_source_buffer(archive, data, sizeof(data), 0); if(source == NULL) { cout &lt;&lt; "failed to create source buffer. " &lt;&lt; zip_strerror(archive) &lt;&lt; endl; return false; } int index = (int)zip_file_add(archive, file.c_str(), source, ZIP_FL_OVERWRITE); if(index &lt; 0) { cout &lt;&lt; "failed to add file to archive. " &lt;&lt; zip_strerror(archive) &lt;&lt; endl; return false; } zip_source_free(source); zip_close(archive); return true; </code></pre> <p>This code throws a runtime error at the <code>zip_close()</code> call.</p> <blockquote> <p>Unhandled exception at 0x00EDDD16 in Application.exe: 0xC00000FD: Stack overflow (parameters: 0x00000001, 0x002C2FFC).</p> </blockquote> <p>Update: I removed the <code>zip_source_free()</code> call since I was told that this is already done by <code>zip_file_add()</code>. Moreover, I check <code>archive</code> to not hold <code>NULL</code>. These changes raised another error at <code>zip_close()</code>.</p> <blockquote> <p>Unhandled exception at 0x0065BC57 in Application.exe: An invalid parameter was passed to a function that considers invalid parameters fatal.</p> </blockquote> <p>What am I doing wrong?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload