• Advertisement
Sign in to follow this  

PhysicsFS and writing to zip archive

This topic is 4169 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello! I've been trying out PhysicsFS and it seems like a really neat library, however it seems that there isn't much information/examples/tutorials out there about it. Or, my googleskills are worthless :( I've been able to read from zip archives with the help of the very minimalistic tutorial on http://www.icculus.org/physfs/ But I cant write back to a file if my life depended on it. The PHYSFS_write() function returns what I expect it to, but the file within the zip stays the same. Is writing back to a zip even possible? Regards /ixi [Edited by - ixilom on September 19, 2006 6:43:42 PM]

Share this post


Link to post
Share on other sites
Advertisement
Of course I used PHYSFS_openWrite =)

Here are the steps I used, sorta in pseudocode (dont have my source available atm)

PHYSFS_init(NULL);
PHYSFS_addToSearchPath("some_file.zip");
PHYSFS_setWriteDir(PHYSFS_getBaseDir());
PHYSFS_file *fp = PHYSFS_openWrite("some_file_in_zip.bin");
PHYSFS_write(fp,myStruct,sizeof(struct myStruct),1);
PHYSFS_close(fp);
PHYSFS_deinit();

All of the above functions return whats expected, in other words, my file in the zip should be updated .. but nope.

Any suggestions?

Share this post


Link to post
Share on other sites
Okay, I wrote a simple test, a zipfile called test.zip containing test.txt. That textfile contains "change me".

Then I run this piece of code

PHYSFS_init(NULL);
if(PHYSFS_addToSearchPath("test.zip",1)) {
if(PHYSFS_setWriteDir(PHYSFS_getBaseDir())) {
PHYSFS_file *fp = PHYSFS_openWrite("test.txt");
if(fp) {
int count = PHYSFS_write(fp,"hello",5,1);
if(PHYSFS_flush(fp)) {
if(count==1) {
int z = 0; // just something I can setup a breakpoint on to see if the code reached this far
}
}
PHYSFS_close(fp);
}
}
}

But alas, the test.txt in the zip stays the same :(
Even added PHYSFS_flush() there just in case, but nothing happened.

Maybe something screwed up when I built the dll/lib in MSVC .NET .. I know I had to hack it some to get it to compile. Replaced some _alloca to alloca. _alloca is alloca on WIN32, just a #define that didn't want to work as it should, but still... its driving me crazy >:|

Share this post


Link to post
Share on other sites
Are you sure that PhysFS supports the feature of writing to zipfiles? last time i checked, only readings were available

Share this post


Link to post
Share on other sites
Hi Wixner!

Thanks for the answer. In the original post I wrote:

"Is writing back to a zip even possible?"

I couldn't find anything that said you cant, only that PhysicsFS supports zip archives. Thanks to you I now know that its not possible =)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I dont think you can write to zip files, in fact im almost sure you can't, you can only read.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement