write files don't work FileStream.Open (glfw)

Monkey Forums/Monkey Programming/write files don't work FileStream.Open (glfw)

GC-Martijn(Posted 2015) [#1]
target: glfw
os: osx yosemite

Why does this simple code not work ?
I want to create some json files (building a small game editor for my game) but test.json
is never created.

- I did try to delete the build folder
- The data folder has all rights
- Search the file test.json (not found)

Local file:FileStream = FileStream.Open( "monkey://data/test.json", "w")
		If not file
			Print "Can't open file"
		Else
			Print "write" ' <--- shows write
			file.WriteInt(1) ' < --- test
			file.Close()
		End



nullterm(Posted 2015) [#2]
Try monkey://internal/test.json

I think data is just for reading files, not sure about desktop/glfw. But for iOS, Android it's definitely the case that you can only load/read.

internal is read & write for anything the app needs to save & load.

http://www.monkey-x.com/docs/html/Programming_Resource%20paths.html
"Use the "monkey://data/" prefix to locate resources that were placed in the app's data/ directory when it was built.
Use the "monkey://internal/" prefix to locate resources stored in the app's internal storage directory."


GC-Martijn(Posted 2015) [#3]
sorry forgot to say that internal dont work.


nullterm(Posted 2015) [#4]
That's odd, I'm using "monkey://internal/config.json" on a project and works both Win and Mac, glfw3.

Are you looking inside your MyGame.app package? I'm not sure the Mac Finder search looks inside of .app "folders". You might need to find the .app, right click, Show Package Contents and browse around inside the app's directories to find the "internal" folder.

Also, which Print shows up on the output, for the "Can't open file" or "write"?




GC-Martijn(Posted 2015) [#5]
Found it

{projectname}.buildv81b/glfw/xcode/build/Debug/MonkeyGame

Then right click "show package content"
Contents/Resources/data (when using monkey://data/) (works)
Contents/Resources/internal (when using monkey://internal) (works)


nullterm(Posted 2015) [#6]
Cool! Didn't know write to data works on desktop. Just be careful, data might get overwritten when you re-build your game. internal is probably safer option to keep your save data alive.