Skip to content

Significant complications when writing an archiver with write support #58

Description

@Torphedo

I'm trying to write an archiver with streaming write support (a simple format covered by the unpacked template). I implemented an openWrite() function I wanted to test, but PHYSFS_openWrite() never reaches it. It fails in verifyPath() because it uses the directory archiver's stat function, determines it doesn't exist, and returns an error.

It calls DIR_stat() here, and here's an example of my source code:

const char packname[] = "Armor_012_Upper.pack";

int main(int argc, char** argv) {
    PHYSFS_init(argv[0]);
    PHYSFS_mount(PHYSFS_getBaseDir(), NULL, true);
    PHYSFS_setWriteDir(PHYSFS_getBaseDir());

    PHYSFS_registerArchiver(&archiver_sarc_default);

    printf("Mounting %s...\n\n", packname);
    PHYSFS_mount(packname, NULL, true);

    PHYSFS_file* test_write = PHYSFS_openWrite("/ActorLink/Armor_012_Upper.bxml");
    printf("%p\n", test_write);
}

I'm able to read the file into a buffer with PHYSFS_openRead() and PHYSFS_readBytes() and write it to disk (I omitted the code for this to keep the code snippet short). So the file definitely exists, and the archiver is registered correctly.

TLDR: Writing has very different behaviour from reading which seems to prevent me from even reaching the writing code in my archiver. I could try to re-implement PHYSFS_openWrite() myself, but I would prefer not to if possible.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions