Bug: DataBuffer not working correct?
Monkey Forums/Monkey Programming/Bug: DataBuffer not working correct?
| ||
I perhaps found a bug! I try to load binary datas on a html5 target. But the returned DataBuffer is NULL when I do not add the whole path: Strict Import mojo Import brl.databuffer Class Game Extends App Method OnCreate%() SetUpdateRate 60 LoadArray Return 0 End Method LoadArray:Void() Local Bank:DataBuffer , t$ Print LoadString("any.txt") 'Bank=New DataBuffer(2*800*8) 'Bank=DataBuffer.Load("monkey://data/" + "unicode.bin") Bank=DataBuffer.Load("unicode.bin") If Bank=Null Print "Not loaded!" Endif End Method Method OnUpdate%() Return 0 End Method OnRender%() Return 0 End End Function Main%() New Game Return 0 End What Do I do wrong? Version is Monkey 75d, the *.data folder is correct, because the "any.txt" is loaded correct. The filename is written correct to... The "*.bin" files are already registered in the default "config.money": #MOJO_AUTO_SUSPEND_ENABLED=True #OPENGL_GLES20_ENABLED=False #TEXT_FILES="*.txt|*.xml|*.json" #IMAGE_FILES="*.png|*.jpg" #SOUND_FILES="*.wav|*.ogg|*.mp3|*.m4a" #MUSIC_FILES="*.wav|*.ogg|*.mp3|*.m4a" #BINARY_FILES="*.bin|*.dat" When I use a complete path it works!!! Bank=DataBuffer.Load("monkey://data/unicode.bin") |
| ||
probably: in LoadString Function LoadString$( path$ ) Return _game.LoadString( FixDataPath(path) ) End but DataBuffer does not add the FixDataPath(path) function. I forget if this was done by design. |
| ||
From 'resource paths' docs... Also, note that Mojo module load commands will automatically insert a "monkey://data/" prefix before any path that does not already incude a prefix. For example, LoadImage( "myimage.png" ) is the same as LoadImage( "monkey://data/myimage.png" ). This is kind of a 'backwards compatibility' kludge for Mojo - the cleanest solution would probably have been to require ALL file paths to be absolute, with perhaps a './' prefix for 'current dir' (on targets that even support it). |