SFML community forums

Help => System => Topic started by: Haikarainen on September 08, 2011, 10:33:24 pm

Title: sf::InputStream newb question
Post by: Haikarainen on September 08, 2011, 10:33:24 pm
Hello, trying to create an InputStream to be able to load files directly from my custom packaging format, but i get a segmentation fault on the Read function.

EDIT; Well what i really wanted to ask what; What is the basic principles of getting sometihng like this to work ? :D

Warning: I have no or very little knowledge of what I am actually doing here, but here goes the sourcecode;

Cpp;
https://legacy.sfmluploads.org/code/82

Hpp;
https://legacy.sfmluploads.org/code/83

my::Data::File::GetContents() returns a char* containing  raw filedata.
Title: Re: sf::InputStream newb question
Post by: coolhome on September 09, 2011, 02:01:54 am
Here you go mate, I think this will work.

https://legacy.sfmluploads.org/code/86
Title: Re: sf::InputStream newb question
Post by: Haikarainen on September 09, 2011, 03:41:29 am
Quote from: "coolhome"
Here you go mate, I think this will work.

https://legacy.sfmluploads.org/code/86

does not
Title: sf::InputStream newb question
Post by: Laurent on September 09, 2011, 07:44:39 am
Could you please provide a complete and minimal source code that reproduces the problem, so that I can test and debug it?
Title: sf::InputStream newb question
Post by: Haikarainen on September 09, 2011, 11:35:19 am
Quote from: "Laurent"
Could you please provide a complete and minimal source code that reproduces the problem, so that I can test and debug it?


No, since i do not know how to do it :O Thats kinda the problem, or is the code right?
Title: sf::InputStream newb question
Post by: Laurent on September 09, 2011, 12:25:58 pm
Quote
No, since i do not know how to do it

You don't know how to reduce your code? It looks simple: provide your InputStream class, and a main that uses it to load a resource. Replace your Data::File class with a std::vector<char>, for example.
Title: sf::InputStream newb question
Post by: Haikarainen on September 09, 2011, 04:05:50 pm
Quote from: "Laurent"
You don't know how to reduce your code? It looks simple: provide your InputStream class, and a main that uses it to load a resource. Replace your Data::File class with a std::vector<char>, for example.


I didn't know how to write the functions properly, however i made it work just now. Apparently one of my functions was broken, stupid mistake :P
Title: sf::InputStream newb question
Post by: Laurent on September 09, 2011, 04:08:42 pm
Quote
I didn't know how to write the functions properly, however i made it work just now. Apparently one of my functions was broken, stupid mistake

Was it a mistake in my::Data::Stream (in this case I'd like to see the fix) or somewhere else in your code?
Title: sf::InputStream newb question
Post by: Haikarainen on September 09, 2011, 04:58:33 pm
Quote from: "Laurent"
Was it a mistake in my::Data::Stream (in this case I'd like to see the fix) or somewhere else in your code?


Somewhere else in my code, my::Data::Package::GetFile returned empty pointers for some reason :S created a my::Data::Package::GetStream instead and now it works fine!

The code that I went with:http:// https://legacy.sfmluploads.org/code/88