physfs icon indicating copy to clipboard operation
physfs copied to clipboard

Get example how to use writre to a zip archive

Open guielec42 opened this issue 2 years ago • 3 comments

Hello,

I'm trying PhyFS, seams really intresting but there is no example how to use write. Result is a corrupted zip file It would be great if I can get some help to understand what is wrong. I'm using 3.3 release. here is my simple code: PHYSFS_init("d:\"); PHYSFS_setWriteDir("d:\");

PHYSFS_mount("d:\\testw.zip", "/" , true);       

const char* writedir =  PHYSFS_getWriteDir();
std::cout << writedir << std::endl; // for testing


PHYSFS_File* txtwtest = PHYSFS_openWrite("/txt2.txt");
int test = PHYSFS_writeBytes(txtwtest, "testwr", 5); // return 5 so it did write somewhere
PHYSFS_close(txtwtest);

PHYSFS_unmount("d:\\test.zip");
PHYSFS_deinit();

guielec42 avatar Aug 14 '23 07:08 guielec42

You can't write to zip files. It (currently) only allows writing to loose files on the actual filesystem.

icculus avatar Aug 14 '23 15:08 icculus

I confirm, I can write to the local filesystem. Is it a limitation due to zip archive or more global ?

On Mon, Aug 14, 2023 at 5:41 PM Ryan C. Gordon @.***> wrote:

You can't write to zip files. It (currently) only allows writing to loose files on the actual filesystem.

— Reply to this email directly, view it on GitHub https://github.com/icculus/physfs/issues/67#issuecomment-1677578901, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKWTBT3ZPS4Q3JADNYHPVDTXVJBK3ANCNFSM6AAAAAA3PIXK5I . You are receiving this because you authored the thread.Message ID: @.***>

guielec42 avatar Aug 15 '23 06:08 guielec42

The API allows it, but it's not implemented for anything but the native filesystem. There are questions about how to rewrite a .zip file to make this work cleanly, since you'd have to deal with the existing data, etc.

icculus avatar Aug 15 '23 14:08 icculus