Problem reading a file
Monkey Forums/Monkey Beginners/Problem reading a file
| ||
Hi all I have problem to read a file. Here is the code: There is a "Default.act" file in my directory and in the subdirectory ".data". But, at the first ReadByte, I receive this error message: "Monkey Runtime Error : Memory access violation"... WHat's wrong with this code ? Any idea ? Thanks Pit |
| ||
I struggled with this too, the documentation is wrong. your .data folder needs to be yourfilename.data |
| ||
Hi Pharmhaus I confirm that the data directory is test.data (as the code is test.monkey). So, should be ok ? Pit |
| ||
I believe your path needs to be "monkey://data/Default.act" or something similar |
| ||
This should work: Just a tip, but when you're dealing with streams, don't use the actual stream class something outputs (Unless that class provides functionality you absolutely need), use 'brl.stream.Stream' (In other words, just the 'Stream' class/type). This will make your code more versatile. EDIT: As Pharmhaus said, the STDCPP/C++ Tool target is not a standard 'BBGame' target like GLFW/Desktop for example, so it won't have a data-folder. And from my experience, the "monkey://" prefix might not work either on this target. For such a situation, you need to either symbolically link the folder over, or copy it over manually (Or vice versa). That being said, if you have the folder there, you can just write "data/Default.act" for that target. |
| ||
please note that the "C++ Tool" does not support the datafolder so this might be another cause. |
| ||
dear ImmutableOctet(SKNG), THANKS ! Your code works ! I tried to modify my code, and the missing part was: #BINARY_FILES += "*.act" ! Adding this make my code running without problem ! a chance that you help me because I didn't see this in the documentation... thanks again pPit |