FileType with Incbin

BlitzMax Forums/BlitzMax Programming/FileType with Incbin

Curtastic(Posted 2007) [#1]
I noticed that FileType does not work with incbin files. I'm using it to load a lot of animations, not knowing how many frames there are for each one.

So I changed it to:
image=loadimage("incbin::image"+i+".bmp")
if image=null then
'file exists
endif

Now I see blitzmax can tell if the image exists in the incbin using loadimage, so why can't I do it directly????

My only problem is that the image is actually loaded if it exists, I want to load images later, after finding out how many there are. I could just keep track of the numbers manually but it woiuld be hard becuase the amount of images in each folder keep changing.

So what is the best hack to tell if a file exists in incbin? I need it to execute as fast as possible.


Blueapples(Posted 2007) [#2]
If IncbinLen("image"+i+".bmp"") = 0 Then
  Notify "File doesn't exist!"
EndIf



Curtastic(Posted 2007) [#3]
Thanks!

I am using this
If (incstring="" And FileType(filename+".bmp")=0) Or (incstring<>"" And IncbinLen(filename+".bmp")=0) Then
'stop loading this anim


Still would be nice if FileType("incbin:: just worked


Brucey(Posted 2007) [#4]
But incbin isn't a real file (after compilation)... it's a pointer to a location in memory.


Curtastic(Posted 2007) [#5]
Well LoadImage works on fake files, and by passing "incbin::" FileType should have that special case also imho


Gabriel(Posted 2007) [#6]
Er.. can't you just use IncBinPtr() instead?

Incbin "C:\COH.jpg"

If IncbinPtr("C:\COF.jpg")
	Print "OK"
End If
If IncbinPtr("C:\COH.jpg")
	Print "OK"
End If


Seems to work for me.


Blueapples(Posted 2007) [#7]
How is that effectively different? I just scrolled down in the manual from Incbin to IncbinLen. It's the next function.
If IncbinPtr("C:\COF.jpg") Then Print "OK"

and
If IncbinLen("C:\COF.jpg") Then Print "OK"

are exactly the same.

"Er.. can't you just " implies your suggestion is somehow simpler, which it is not.

Sorry I'm not having the best day at work.


Gabriel(Posted 2007) [#8]
How is that effectively different?

are exactly the same.

"Er.. can't you just " implies your suggestion is somehow simpler, which it is not.


It isn't different. Your reply and Curtastic's second post are so close together that I saw your message and his code as being in the same reply, which clearly they're not.

Sorry.


Blueapples(Posted 2007) [#9]
Heh. Like I said. Didn't mean to snap at you. Someone just copied my only code arch entry and said they wrote it. I'm too sensitive this week.


Brucey(Posted 2007) [#10]
Btw, thanks for that code-entry, Blueapples... led me to find a cross-platform xBase lib I could use :-)

Curtastic... LoadImage is a special-case... and actually only works if you have BRL.RamStream imported (assuming you are using a Framework - which you should, really).

To have FileType work in the same way, would probably mean tying BRL.FileSystem to other modules that it has no business relying on...