SFML community forums

General => SFML wiki => Topic started by: FRex on April 09, 2013, 06:56:56 am

Title: Physics Filesystem
Post by: FRex on April 09, 2013, 06:56:56 am
I've added example code of sf::InputStream that uses PhysicsFS (http://icculus.org/physfs/) to load from disc or some archive(it's all transparent and abstracted away by physics).
Can someone please double check formatting and that I didn't break the main Sources page or something?

https://github.com/SFML/SFML/wiki/Sources

https://github.com/SFML/SFML/wiki/Source%3A-PhysicsFS-Input-Stream

This will be helpful next time someone molests Laurent about SFML needing a filesystem.. :P
Title: Re: Physics Filesystem
Post by: Tank on April 09, 2013, 08:08:47 am
Looking all good.
Title: Re: Physics Filesystem
Post by: Laurent on April 09, 2013, 08:14:55 am
To be extremely picky, I would add open/close functions to the stream class, rather than giving it directly a PHYSFS_FILE*. This way it is perfectly encapsulated, and has the same interface as other file streams (like std::ifstream).
Title: Re: Physics Filesystem
Post by: FRex on April 09, 2013, 09:05:58 am
Quote
To be extremely picky
>:( ;D
Done, hope I didn't introduce a mistake now..
Title: Re: Physics Filesystem
Post by: Laurent on April 09, 2013, 09:19:03 am
Looks good, but open should return a boolean ;)
Title: Re: Physics Filesystem
Post by: eXpl0it3r on April 09, 2013, 09:26:12 am
Nice! :)
I always wanted to look into that, but never got around to do it.
Title: Re: Physics Filesystem
Post by: FRex on April 09, 2013, 11:02:51 am
Quote
Looks good, but open should return a boolean ;)
>:( ;D Done too. Really, it's just to show that it's possible and easy not to be best designed API ever.
Title: Re: Physics Filesystem
Post by: Laurent on April 09, 2013, 11:07:39 am
The code is so small, there's no reason to have it badly designed ;)
Title: Re: Physics Filesystem
Post by: Tank on April 09, 2013, 03:54:06 pm
Sorry for this useless post, but: lol
Title: Re: Physics Filesystem
Post by: FRex on April 09, 2013, 09:10:09 pm
Quote
Sorry for this useless post, but: lol
LoL. ;D ;D
Quote
The code is so small, there's no reason to have it badly designed ;)
void main(){}

Thanks for re-edit, whoever did it. My style of coding isn't very friendly. ;D

Turns out we forgot to null out file handle when we close so it didn't really look like it closed(we held invalid pointer). ;D Fixed.
Title: Re: Physics Filesystem
Post by: FRex on February 06, 2018, 02:07:32 pm
I've updated it a tiny bit, added C++ to ``` to make code colored, split it into hpp and cpp, added sf::NonCopyable as a base to make it more secure, etc.
Title: Re: Physics Filesystem
Post by: GRAHAMO on July 31, 2019, 02:51:13 pm
Decent, need to accomplish something like this with mine.