gamecreator Posted July 23, 2017 Share Posted July 23, 2017 I have a text file in a zip package I'm trying to read. The zip loads successfully and the contents show the txt file is there. However, when I tried to load it with FileSystem::OpenFile("text.txt"), the function fails. But if I put the text file into the folder by itself, the function succeeds (loading it directly, not from the zip file). Does this just mean that FileSystem does not work with Package? I'd love to have zipped text files which provide data to my game (like NPC conversations). I could try to use Package::ExtractFile to do this the long way but I'd really rather not extract files just so I can access them and have them be publicly available, defeating the purpose of password protecting them. In researching a solution for this, I saw that this came up 3 years ago, without a solution. Code, if it helps: Package *package=NULL; package=Leadwerks::Package::Load("text.zip",""); if(package==NULL) printf("Package load failed\n"); else { printf("Package loaded\n"); printf("Number of files: %d\n",package->CountFiles()); cout << package->GetFileName(0) << endl; cout << package->GetFileName(1) << endl; } Stream *stream = FileSystem::OpenFile("text.txt"); if(stream==NULL) printf("open failed\n"); else System::Print(stream->ReadLine()); 1 Quote Link to comment Share on other sites More sharing options...
gamecreator Posted July 26, 2017 Author Share Posted July 26, 2017 Out of curiosity, I tried to publish the project as Standalone, added the txt extension to include and unchecked "Only include used files." I removed the zip loading code, only looking to read from a txt file inside data.zip, using the last three lines of the above code. The load failed. Tried with a mat file and that failed as well. So it seems FileSystem doesn't work at all with Package or even the Leadwerks data.zip file, which is too bad. 1 Quote Link to comment Share on other sites More sharing options...
gamecreator Posted July 26, 2017 Author Share Posted July 26, 2017 That's great! It works from the Package. Thank you! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.