- Joined
- Jan 2, 2020
- Messages
- 569
Here's an utility to help you while you are experimenting and you need quick access to files.
It gives you the path to where your .cxs files is happen to be residing in.
This makes it possible to read and write your files if you work on your desktop for instance.
Nice utility to have around at times.
There's a windows and macOS version!
It gives you the path to where your .cxs files is happen to be residing in.
This makes it possible to read and write your files if you work on your desktop for instance.
Nice utility to have around at times.
There's a windows and macOS version!
code_language.cerberus:
#GLFW_WINDOW_WIDTH = 1280 ' ------------------------------------
#GLFW_WINDOW_HEIGHT = 720 '
Strict ' Findpath utility, an easy way
Import mojo2 ' finding paths
Import brl '
Import OS ' ------------------------------------
Function Main : Int()
New Game()
Return 0
End
Class Game Extends App
Field canvas : Canvas
Method OnCreate : Int()
canvas=New Canvas
Return 0
End
Method OnRender : Int()
canvas.Clear
canvas.Flush
Return 0
End
Method OnUpdate:Int()
If KeyHit(KEY_ESCAPE) Then EndApp
If KeyHit(KEY_S) Then pathfinder()
Return 0
End
Method pathfinder:Void()
' FIND PATH WHERE THE ACTUAL .CXS FILE RESIDES IN
Local exeRoot := RealPath(ExtractDir(AppPath()))
' macOS version
' Local path := RealPath(exeRoot+"/../../../../../../../../")+"/"
' Windows version
Local path := RealPath(exeRoot+"/../../../../") ' note that you don't add "/"
' Linux version
' ?
' Example how to use, open a filestream
Local dump := New FileStream(path+"myfile.txt","w")
dump.WriteString "WORKS!"
dump.Close
' ----------------------------------------------------------------------
End
End