Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

Blake Ramsdell

Member Since 18 Aug 2010
Offline Last Active Nov 16 2012 11:12 PM
-----

#21914 Reading binary resources piecemeal

Posted by Blake Ramsdell on 20 December 2011 - 05:21 PM

If only there was a way to implement a test of code to see if it works. An "automated test" if you will.

http://netmf.codeplex.com/

client_v4_2/CLR/Libraries/CorLib/corlib_native_System_Resources_ResourceManager.cpp

if(offset + length >= size)
{
    length -= size - offset; 
}

Seems like this is wrong in at least a couple of ways. I think:

if((offset + length) > size)
{
    length = (size - offset);
}
Is both clearer and less buggy.

So I think in your first case you ended up with:

if(0 + 8 >= 8)
{
    length -= 8 - 0;
}
So your length ended up as 0 in this case.

if(0 + 20 >= 8)
{
    length -= 8 - 0;
}
So your length ended up as 12 in this case (8 bytes of your resource data and four bytes of god knows what).

Happy to submit a patch, but I need to spend an hour and figure out how to do it and get the code. I was able to figure this out by browsing the source on CodePlex.

I'd say in the interim just make your resource one byte larger than you need. So nine bytes and then just know that the first eight are the "real" resource.


home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.