rlm@1: // for retrieving files from archives and/or managing temporary files rlm@1: rlm@1: #ifndef OPENARCHIVE_HEADER rlm@1: #define OPENARCHIVE_HEADER rlm@1: rlm@1: #include "7zip.h" rlm@1: rlm@1: // ObtainFile() rlm@1: // this is the main, high-level function for opening possibly-compressed files. rlm@1: // you don't need to check whether the file is compressed beforehand, rlm@1: // this function will figure that out and work correctly either way. rlm@1: // it also does the work of bringing up a within-archive file selector dialog if necessary, rlm@1: // which even allows navigating to a file within an archive that's within the archive. rlm@1: // the output PhysicalName is the filename of an uncompressed file rlm@1: // for you to load with fopen or whatever, rlm@1: // unless the function fails (or is cancelled) in which case it will return false. rlm@1: // example input Name: "C:\games.zip" rlm@1: // example output LogicalName: "C:\games.zip|Metroid.gba" rlm@1: // example output PhysicalName: "C:\Documents and Settings\User\Local Settings\Temp\VBA\rom7A37.gba" rlm@1: // assumes the three name arguments are distinct character buffers with exactly 2048 bytes each rlm@1: bool ObtainFile(const char* Name, char *const & LogicalName, char *const & PhysicalName, const char* category=NULL, const char** ignoreExtensions=NULL, int numIgnoreExtensions=0); rlm@1: rlm@1: // ReleaseTempFileCategory() rlm@1: // this is for deleting the temporary files that ObtainFile() can create. rlm@1: // using it is optional because they will auto-delete on proper shutdown of the program, rlm@1: // but it's nice to be able to clean up the files as early as possible. rlm@1: // pass in the same "category" string you passed into ObtainFile(), rlm@1: // and this will delete all files of that category. rlm@1: // you can optionally specify one filename to not delete even if its category matches. rlm@1: // note that any still-open files cannot be deleted yet and will be skipped. rlm@1: void ReleaseTempFileCategory(const char* category, const char* exceptionFilename=NULL); rlm@1: rlm@1: // sets the parent window of subsequent archive selector dialogs rlm@1: // NULL resets this to the default (main VBA emulator window) rlm@1: void SetArchiveParentHWND(void* hwnd=NULL); rlm@1: rlm@1: // the rest of these are more internal utility functions, rlm@1: // but they could be generally useful outside of that rlm@1: const char* GetTempFile(const char* category=NULL, const char* extension=NULL); // creates a temp file and returns a path to it. extension if any should include the '.' rlm@1: void ReleaseTempFile(const char* filename); // deletes a particular temporary file, by filename rlm@1: int ChooseItemFromArchive(ArchiveFile& archive, bool autoChooseIfOnly1=true, const char** ignoreExtensions=0, int numIgnoreExtensions=0); // gets an index to a file within an already-open archive, using the file chooser if there's more than one choice rlm@1: rlm@1: #endif