libarchive: dump memory archive to disk file
Hi,
Libarchive version: 3.1.2 I'm creating the archive in memory with: Code:
archive_write_open_memory(a, abuf, ABUF_SIZE, &asize); Code:
write(fd, abuf, asize); Code:
tar -xf output2.tar.gz Code:
write(fd, abuf, ABUF_SIZE); Can you please explain me what am I missing? -- Best regards, Andrzej Telszewski |
Hi,
I did some code refactoring and it magically started to work correctly. I don't know what happened and if it is going to be like that throughout the whole development cycle;) Could somebody please confirm that the code I posted in the first post, should actually work and behave as expected (that is that with this code I should get correct on-disk archive)? -- Best regards, Andrzej Telszewski |
You didn't show enough code to determine what might be wrong, so I modified the "man archive_write" example code to use "archive_write_open_memory" and it worked fine:
Code:
#ifdef __linux__ |
Hi,
@norobro thank you for confirmation. I based my code on the same example as you, plus some changes based on A Basic Write Example. Is this part of any importance: Code:
#ifdef __linux__ Below comes my code, so if you have some comments, let me know. It's a C++ class, size and data are class members, for archive size and data buffer respectively. Code:
/// Maximal archive size. Code:
/******************************************************************************/ Best regards, Andrzej Telszewski |
Quote:
Quote:
I'm a little "goto" averse, so I would probably use try, throw, catch to handle errors. |
Hi,
First of all thank you for taking the time to test the class in operation, I really appreciate that. Since then I slightly cleaned up the code and removed what seemed to be excess of code. When it comes to _FILE_OFFSET_BITS I see I won't need it. My program is going to be run only on Linux and archives are going to be very small in size. Quote:
I'm aware that throw & company would be more of C++ way of doing the things but, as I said, my knowledge is limited, so I prefer to use the known subset of C++. Thanks for the help! -- Best regards, Andrzej Telszewski |
Hi,
I'm marking as solved. It seems I had an error somewhere, other than that the solution is correct. -- Best regards, Andrzej Telszewski |
All times are GMT -5. The time now is 03:10 AM. |