FileType fails for files in data folder (android)

Monkey Forums/Monkey Bug Reports/FileType fails for files in data folder (android)

Skn3(Posted 2015) [#1]
FileType does not work with a file stored in your data folder. It always returns 0. I have tested loading the contents of a text file into databuffer and it works, but FileType on the same path does not.


Skn3(Posted 2015) [#2]
Seems as though FileSize also doesn't work


marksibly(Posted 2015) [#3]
Data files on android are not actually files - they're assets, embedded in a zip.

To be able to treat them as proper files, you'll need to copy them to monkey://internal/ first or something.


Skn3(Posted 2015) [#4]
Thought this might be the case, same in XNA. Maybe monkey could create special compiled functions AssetFileSize and AssetFileType which contain select statement for all file paths in data folder? Then trans could read the file sizes at compile time and hard code them?

It's not really that "clean" but beats having to open the file to determine the details...


EdzUp(Posted 2015) [#5]
Or read the file into a DataBuffer before checking the type or size? This way FileType and FileSize can be used.

The only adjustment would be checking the target, and the loading into DataBuffer :)


Skn3(Posted 2015) [#6]
Yeah I have this now but it seemed like there could be a smarter approach. I think the html5 target already adds meta data for images, so could be useful to flesh it out a bit.