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

Author Topic: [Released] libMy - Datapackaging library  (Read 32170 times)

0 Members and 1 Guest are viewing this topic.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
[Released] libMy - Datapackaging library
« Reply #30 on: November 15, 2011, 05:20:14 pm »
Quote from: "Silvah"
On this forum it's Nexus's job to do that, not mine ;)

 :lol:

I guess there are a few more bugs to fix...  :wink:

I'll keep looking and reporting.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Haikarainen

  • Guest
[Released] libMy - Datapackaging library
« Reply #31 on: November 16, 2011, 04:54:08 am »
Quote from: "Silvah"
Quote from: "eXpl0it3r"
Code: [Select]
// At the moment
if(strcmp(firstcheck, "MPF") != 0){
// But should acutally be
if(strncmp(firstcheck, "MPF", 3) != 0){
Actually, it should be
Code: [Select]
if(memcmp(firstcheck, "MPF", 3) != 0){ to emphasize it's really a binary comparison.


Well is this really neccessary? Do you know of any platform that these 2 different methods give different results in a scenario like this?


Quote
Can I nitpick some more? ;)

So, why on Earth earlier in the same function it's
Code: [Select]
char* firstcheck;
firstcheck = new char[3];
and not the vastly simpler
Code: [Select]
char firstcheck[3];?

Good point, The original code worked flawlessly for me so I really didnt think about initializing it whatsoever.

Quote
Why there are so much unadorned new[] and delete[]s in the code? Familiarize yourself with RAII and classes like std::vector or boost::scoped_array. It'll make the code simpler, easier to read and write, and more correct. Are you sure there are not memory leaks? I'm not. Given that there are so many ways for things to go wrong, I wouldn't dare to ignore RAII.


Unadorned? They are the reason the lib is NOT  filled with memoryleaks(I have tested this extensively and I have not detected a single byte escaping. Also I'm 100% sure filedata does not escape). Stop taking idioms so overseriously.

Also, I know std::vector, I use it very often. But would you REALLY store filedata using an std::vector? Wouldn't that be both stupid and slow?

Quote
Why all the loop counters are of type int, not container::size_type (in most cases the same as std::size_t)? You not only have to cast to silence a warning about comparison between signed (int) and unsigned (size_t), you also make the code not work for all sizes larger than INT_MAX. On some common platforms, size_t is in fact larger than int, so the code may crash in a funny way.

I meant to write (signed) before *.size but  then I remembered this is not how to iterate a vector properly. This is on my todolist (iterate vectors properly using std::vector<T>::iterator and not ints).

Quote
Why all the std::strings are passed to functions by value? Pass by a reference to a constant, you'll get rid of unnecessary copying. It's very common idiom, so everyone will understand what you mean.

Why you're returning after throwing an exception? These returns are unreachable, throw already changes the control flow so much you probably are in a completely different function now, so the returns will have no chance to get executed.

.. They are strings, not RenderWindows (for example). do you really have so little time to be THAT nitpicky? But I guess your right I could use const char* instead.


Quote
Why I'm nitpicking on such issues? On this forum it's Nexus's job to do that, not mine ;)
Anyway, it's a nice library, keep on working on it, even though it uses it's own format instead of something widely supported. Could you document the details about the package's binary structure?


Well thank you.  Yes when it's actually done, as stated this is a too early release on request by the "public domain". I have also made clear why I use my own custom format. The fact that you're questioning it gives me suspicions that you don't even know what the goal use of this lib is. If you made a game would you want anyone to be able to open your datafiles using winzip, and maybe a bit of bruteforce?

Haikarainen

  • Guest
[Released] libMy - Datapackaging library
« Reply #32 on: November 16, 2011, 04:54:41 am »
Quote from: "eXpl0it3r"
I'll keep looking and reporting.


Thanks, appreciated :)

Silvah

  • Guest
[Released] libMy - Datapackaging library
« Reply #33 on: November 16, 2011, 05:33:20 pm »
Quote from: "Haikarainen"
Well is this really neccessary? Do you know of any platform that these 2 different methods give different results in a scenario like this?
I'm talking about readability here. You want to compare the first three bytes, right? So use the function that makes it clear you're comparing raw bytes, not strings of characters.

Quote from: "Haikarainen"
They are the reason the lib is NOT  filled with memoryleaks(I have tested this extensively and I have not detected a single byte escaping. Also I'm 100% sure filedata does not escape).
They are the reason you have to write more code and to be very careful. And to check it later. If you relied on RAII instead, a quick glimpse over the code would do.

Quote from: "Haikarainen"
But would you REALLY store filedata using an std::vector?
Sure, why not? File data is an array of bytes. std::vector is a dynamic array. I think it's perfectly good (in fact, quite natural) to store what's an array in an array.
Quote from: "Haikarainen"
Wouldn't that be [...] slow?
Any decent compiler would optimize it out. If the performance still concerns you, you can use boost::scoped_array instead of a vector.

Quote from: "Haikarainen"
They are strings, not RenderWindows (for example).
Apart from RenderWindow being noncopyable, so you couldn't pass it by value, it's just a good and widely recognized practice to pass a heavy-to-copy objects, including containers, which strings are, by a reference to a constant.
Quote from: "Haikarainen"
do you really have so little time to be THAT nitpicky?
Okay, this question puzzles me. Did you mean "do you really have so much time"? Well, yes, I do ;). And you don't have to be defensive, I'm only trying to be helpful :roll:

Quote from: "Haikarainen"
I have also made clear why I use my own custom format.
Apparently I haven't noticed it. So, could you give a link or something?
Quote from: "Haikarainen"
If you made a game would you want anyone to be able to open your datafiles using winzip, and maybe a bit of bruteforce?
Why not? If someone would want to make a mod or something like that, I'd actually like them to do that. On the other hand, if someone would want to steal it, you're protected by the law anyway. And if someone really would want to steal it, she could simply take a screenshot ;)

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
[Released] libMy - Datapackaging library
« Reply #34 on: November 16, 2011, 08:08:58 pm »
Well I want to provide support for mods as well but since I am exposing the engine trough javascript inside my editor it won't be a problem. Actually I see it as an advantage because I can use the exact same system to release expansions/DLC.

So having your own format has the pro that you can protect your own code and let modders protect their code. As long as one does not have the key of course.

It's not Bullet proof no. But I don't see any big con's for not having a custom format.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Haikarainen

  • Guest
[Released] libMy - Datapackaging library
« Reply #35 on: November 17, 2011, 07:42:32 am »
Quote from: "Silvah"
...


Sadly, there are so many issues with the way you think, I cant afford the time or care to answer them all.

Silvah

  • Guest
[Released] libMy - Datapackaging library
« Reply #36 on: November 17, 2011, 03:07:40 pm »
Quote from: "Haikarainen"
Sadly, there are so many issues with the way you think, I cant afford the time or care to answer them all.
Please, what's wrong with you? I really don't mean to offend anyone, I'm only trying to point out what I think should be changed in the code.

So why you're resorting to what's basically a glorified name-calling? Seriously, if I'm doing something wrong, I'd be very glad to hear why it's so wrong, so I can work on it in order to not let it happen again in the future.

Haikarainen

  • Guest
[Released] libMy - Datapackaging library
« Reply #37 on: November 17, 2011, 03:15:15 pm »
Quote from: "Silvah"
Quote from: "Haikarainen"
Sadly, there are so many issues with the way you think, I cant afford the time or care to answer them all.
Please, what's wrong with you? I really don't mean to offend anyone, I'm only trying to point out what I think should be changed in the code.

So why you're resorting to what's basically a glorified name-calling? Seriously, if I'm doing something wrong, I'd be very glad to hear why it's so wrong, so I can work on it in order to not let it happen again in the future.


I dont mean to offend you either, and you make some good points(memcmp etc), but there are a lot of points your making that I cant agree with at all, and I cant explain why without responding with way too much text.

Silvah

  • Guest
[Released] libMy - Datapackaging library
« Reply #38 on: November 17, 2011, 07:12:55 pm »
Quote from: "Haikarainen"
there are a lot of points your making that I cant agree with at all, and I cant explain why without responding with way too much text.
So what should we do know? I stand by what I said, I won't give up easily, as I don't even know what are you disagreeing with, let alone why ;)

eot

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: MyLib, Datapacker, File integrity checker osv
« Reply #39 on: January 12, 2012, 11:33:34 pm »
Quote from: ".teri"
Quote from: "Haikarainen"


With SFML (WIP):
Code: [Select]

my::Data::Package Test;
Test.Load("Test.pkg");

sf::Image Img;
Img.LoadFromMemory(Test.GetFileData("irimage.png"), Test.GetFileSize("irimage.png"));
Test.Close();




I dont know... sf::InputStream is created for avoid load resources from memory.


Sorry for being a baddie and asking stupid questions, but what's the advantage of using sf::InputStream instead of LoadFromMemory?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
[Released] libMy - Datapackaging library
« Reply #40 on: January 13, 2012, 08:07:55 am »
Quote
Sorry for being a baddie and asking stupid questions, but what's the advantage of using sf::InputStream instead of LoadFromMemory?

The syntax is slightly nicer, and it adds another layer of abstraction, so if the public API of my::Data::Package changes, you only have one class in the code to modify.

Code: [Select]
my::Data::Package Test;
Test.Load("Test.pkg");

my::Data::InputStream stream(Test, "irimage.png");

sf::Image Img;
Img.LoadFromStream(stream);
Test.Close();
Laurent Gomila - SFML developer

Ptlomej

  • Newbie
  • *
  • Posts: 48
    • ICQ Messenger - 353167418
    • View Profile
    • Local
[Released] libMy - Datapackaging library
« Reply #41 on: March 18, 2012, 03:52:05 pm »
How to Build it oô ? I use msvc2010pro can anyone help me please :S

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
[Released] libMy - Datapackaging library
« Reply #42 on: March 18, 2012, 05:33:10 pm »
Quote from: "Ptlomej"
How to Build it oô ? I use msvc2010pro can anyone help me please :S


Unfortunatly Haikarainen doesn't provide a cross platform way to compile the library easily, but if you're using Win64 use the provided binaries.

It's quiet simple to build the library on your own, if you know what you're doing. Just create a new project, add the source files, go to the settings and add all the dependencies, switch to building a library rather than an application.
I can't give you a step by step explenation but I think you'd also learn more if you tried it on your own.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Ptlomej

  • Newbie
  • *
  • Posts: 48
    • ICQ Messenger - 353167418
    • View Profile
    • Local
[Released] libMy - Datapackaging library
« Reply #43 on: March 18, 2012, 06:06:29 pm »
Hmm okay thats bad i need something like pkg who i can insert all my data crypted.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
[Released] libMy - Datapackaging library
« Reply #44 on: March 18, 2012, 06:13:57 pm »
Regarding building the library I just remembered it also uses boost, so it won't be such a smooth and easy ride, except if you love bjam...

Quote from: "Ptlomej"
where i can insert all my data encrypted.


Then libMy is anyway nothing for you since it doesn't support encryption at all or not yet. :wink:
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/