Skip to content

Add support for reading and writing VPK archives without a dependency on the file system? #26

@0xFurtiv

Description

@0xFurtiv

In order to create a VPK archive using this project, the files must first exist in the OS's file system. If I read a file and perform some simple string transformations on it in-memory, I would currently need to write the file back to the OS's file system in order to create a VPK archive using this package.

It would be nice if we could create a VPK archive without depending on the OS's file system. This would allow for more flexibility with the project, especially if we could dependency inject a mock file system for unit tests.

One possible proposal is to change the NewVPK constructor API of this package to accept a file system object rather than a path to a directory. An example using PyFilesystem could look like

from fs import open_fs

with open_fs('./some/directory') as some_dir:
    vpk.new(some_dir).save("output.vpk")

PyFilesystem supports in-memory file systems, which could be used in place of open_fs('./some/directory') to enable unit tests that do not need to access the OS's file system. Support for creating VPK archives from ZIP and TAR archives for free seems like a neat bonus.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions