Here, I store any Python code that I made. There modules, really.
A module that takes multiple files and puts them in one. It's probably good if you're making a game with many sounds and want to encrypt them.
It's not very hard to use.
First, import it.
Then, create a new instance.
'my_packfile=pack.pack()' The constructor takes no parameters. Methods you can use are: Note: Ignore the wierd way I wrote the function declarations.
bool add(string filename): Adds filename to the pack and returns true on success, or raises an exception if the file can't be found.
string get_files(): Gets the list of files stored in this pack and returns a list of strings.
bool extract(string filename, string dest): Extracts filename to the file dest, overwriting it if it exists. Returns true on success and prints an error to sys.stdout on failure. It doesn't raise an exception though, probably..
bool generate(string filename, string key): Writes the pack files data to filename, using key to encrypt the data. Key can be of any length.
bool load(string filename, string key): Loads a pack data created by generate() from filename, using key to decrypt the data. Returns true on success. Raises key error if the key is invalid. Will not work properly if you don't load a valid pack file.
bytes get_bytes(string filename): Returns the decrypted, decompressed contents of filename from the pack file if it's there, or raises an error.
module run_as_bytecode(string filename, string name='pack_file'): Assuming filename is a pyc (compiled Python bytecode file) inside the pack file currently loaded or being made, attempts to return a module, of the sort import os returns for example, that you can then use as a normal imported module. Note that if this module requires other modules in the pack , there is currently no easy way for them to all be imported at once, unless you want to try and use sys.modules.
Other special things:
You can use the len() function on a pack instance, which returns the number of files it has.
Note: Unless I specifically note that pack files are incompatible, upgrading to a new version of this module will not stop you from loading your pack files.