Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Easy way to load files from zip  (Read 17362 times)

0 Members and 1 Guest are viewing this topic.

Bizarreofnature

  • Newbie
  • *
  • Posts: 48
    • View Profile
Easy way to load files from zip
« on: February 05, 2018, 10:27:44 pm »
Hello!

When it comes to streams and stuff im kinda helpless.

Im searching for an easy way to load for example .tga files from a zip file.

Forgive me for being such a noob.
Ive googled hours and checked every single thread in subforum System.
Without success of course.

Thanks in advance!

Best regards,
Bizarreofnature

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Easy way to load files from zip
« Reply #1 on: February 06, 2018, 06:32:44 am »
See https://icculus.org/physfs/ and https://github.com/SFML/SFML/wiki/Source:-PhysicsFS-Input-Stream

The code on wiki is mine from a few years ago and a bit bad. I might rewrite it today. Done.
« Last Edit: February 06, 2018, 02:05:53 pm by FRex »
Back to C++ gamedev with SFML in May 2023

Bizarreofnature

  • Newbie
  • *
  • Posts: 48
    • View Profile
Re: Easy way to load files from zip
« Reply #2 on: February 08, 2018, 03:55:38 pm »
Sorry for late respond and thank you very much for your help. This is awesome. So easy.

But I have a problem. I cant find this file:

Quote
#include "PhysFsStream.hpp"

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Easy way to load files from zip
« Reply #3 on: February 08, 2018, 03:58:36 pm »
The wiki page has 3 files in it: PhysFsStream.hpp, PhysFsStream.cpp and example.cpp. You should create all three and copy the contents from it. You'll also need to get physfs library itself from somewhere else too (easiest is to build it yourself, since it doesn't provide prebuilt packages for a while now).
Back to C++ gamedev with SFML in May 2023

Bizarreofnature

  • Newbie
  • *
  • Posts: 48
    • View Profile
Re: Easy way to load files from zip
« Reply #4 on: February 08, 2018, 07:32:38 pm »
You'll also need to get physfs library itself from somewhere else too (easiest is to build it yourself, since it doesn't provide prebuilt packages for a while now).

And this is the point where im clueless again.
I downloaded CMake but i have no idea how to build these libraries.

Is there any tutorial how to build physicsfs?

Bizarreofnature

  • Newbie
  • *
  • Posts: 48
    • View Profile
Re: Easy way to load files from zip
« Reply #5 on: February 08, 2018, 07:52:51 pm »
Its ok i got it working.. thanks!  :)

Althoug id love to know how to create the lib files..
« Last Edit: February 08, 2018, 08:01:50 pm by Bizarreofnature »

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Easy way to load files from zip
« Reply #6 on: February 08, 2018, 09:01:46 pm »
How did you get it to work without building it?
Back to C++ gamedev with SFML in May 2023

Bizarreofnature

  • Newbie
  • *
  • Posts: 48
    • View Profile
Re: Easy way to load files from zip
« Reply #7 on: February 08, 2018, 09:04:56 pm »
By including all files to my project... which is ugly and noobish.
Id really like to make libs and include them the right way.

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Easy way to load files from zip
« Reply #8 on: February 08, 2018, 09:14:13 pm »
Just open CMake GUI, drag CMakeLists.txt into it and then pick your compiler and generate files for it (for VS it'll be a sln with few projects).
Back to C++ gamedev with SFML in May 2023

Bizarreofnature

  • Newbie
  • *
  • Posts: 48
    • View Profile
Re: Easy way to load files from zip
« Reply #9 on: February 08, 2018, 10:13:03 pm »
Thank you.

So Ive created physfs.lib and included it to my project.

And now:

Quote
PHYSFS_AddToSearchPath ("Game.zip", 1);

is not defined.  :(

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Easy way to load files from zip
« Reply #10 on: February 08, 2018, 10:17:08 pm »
Once you have the lib and headers the process to use them is the same as with SFML.
Back to C++ gamedev with SFML in May 2023

Bizarreofnature

  • Newbie
  • *
  • Posts: 48
    • View Profile
Re: Easy way to load files from zip
« Reply #11 on: February 08, 2018, 10:26:03 pm »
I know.. but for some reason it doesnt work. Let me write it down:

Quote
#include <PhysicsFS/physfs.h>

this is how i include it to my project.

Quote
PhysicsFS/lib/

the place of the lib files

Quote
PhysicsFS/include/PhysicsFS/

place of my headers

And the vs config is EXACTLY the same as the sfml one.

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Easy way to load files from zip
« Reply #12 on: February 08, 2018, 10:27:33 pm »
The lib should also be added to AdditionalDependencies in linker input settings.
Back to C++ gamedev with SFML in May 2023

Bizarreofnature

  • Newbie
  • *
  • Posts: 48
    • View Profile
Re: Easy way to load files from zip
« Reply #13 on: February 08, 2018, 10:37:05 pm »
Yes i did, however its not working.
I wonder.. is it really only one single lib? i have a normal one and a static one.

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Easy way to load files from zip
« Reply #14 on: February 08, 2018, 10:38:52 pm »
Yes, it's a single library. It just can be built as dynamic or static but you need one one of them.
Back to C++ gamedev with SFML in May 2023

 

anything