Can't load file, but it definitely exists
Monkey Forums/Monkey Programming/Can't load file, but it definitely exists
| ||
I don't understand why I'm having trouble with this! I'm using 79e but I tried 80a as well and got the same result. What am I doing wrong? I'm building for OSX Desktop. Thanks, Lindsay Strict Import brl.filestream Function Main:Int() Local packedFile: FileStream ' This doesn't work Local path: String = "languages/english.idx" ' This doesn't work either ' Local path: String = "monkey://data/languages/english.idx" ' This DOES work - but you'd have to modify it for your directory structure, obviously ' Local path: String = "/Users/lindsay/Monkey/Learning/wlt/wlt.data/languages/english.idx" ' This fails on my system with "Failed to open stream", but the file definitely exists in data/languages/ packedFile = New FileStream(path,"r") Print "File opened" packedFile.Close() Return 0 End Download the code and data file here |
| ||
The .idx file does not get copied by default, as it is an unknown file extension. Add: #BINARY_FILES += "*.idx" and use the second version: monkey://data/ Strict #BINARY_FILES += "*.idx" Import brl.filestream Function Main:Int() Local packedFile: FileStream ' This doesn't work 'Local path: String = "languages/english.idx" ' This doesn't work either Local path: String = "monkey://data/languages/english.idx" ' This DOES work - but you'd have to modify it for your directory structure, obviously ' Local path: String = "/Users/lindsay/Monkey/Learning/wlt/wlt.data/languages/english.idx" ' This fails on my system with "Failed to open stream", but the file definitely exists in data/languages/ packedFile = New FileStream(path,"r") Print "File opened" packedFile.Close() Return 0 End Tested with GLFW/Desktop target on Mac OS X, it works. The data files are not always copied (for example with C++ target), so it may not work with all targets. Also note, on Mac OS X, the data/internal/external/ files are within your .app file, in folder Your.app/Contents/Resources/... Right-click your .app and choose "show package contents" to show the .app internals. |
| ||
Oh, so that's what those do! Thanks Danilo, working here now too :) |