Legacy GM How do I get the non-sandboxed executable directory?

I am using game maker to create a utility that will read a file that exists in the same directory as the utility's executable.

How can I get that directory?

for example:
If my executable is
/home/brandon/desktop/dialog/runner
or
C:\dialog\runner.exe​
I want to get the following directory
/home/brandon/desktop/dialog/
or
C:\dialog\​

More detailed information:
The utility I am making has two parts, the editor, and the runner. The editor is a java application that creates dialog files, and the runner is a game maker application that reads these dialog files for testing purposes for a game I am creating. From the editor (java application) I want to save a dialog file, execute the runner (game maker application), and pass the runner the location of that dialog file. The runner will then proceed to read the file and display its contents using my dialog system. My initial thought was to just pass the runner a command line argument on startup that pointed to the dialog file location, but I can see no way of reading command line arguments from gamemaker. My next thought was to have an ini file in the runner executable directory that would contain the location of a dialog file. The runner would then just read that ini file, get the dialog file location, and then read the dialog file.​

I am open to all ideas on how to accomplish this task.
 
C

Ctl-F

Guest
Command line arguments: parameter_count parameter_string
However that still won't get you an unsandboxed directory. The only way to get an unsandboxed directory is to have the user select the file with get_save_filename and get_open_filename
Or you can use an older version of gm. One more idea is to have your java application to save to the gm game/safe directory
 
Command line arguments: parameter_count parameter_string
However that still won't get you an unsandboxed directory. The only way to get an unsandboxed directory is to have the user select the file with get_save_filename and get_open_filename
Or you can use an older version of gm. One more idea is to have your java application to save to the gm game/safe directory
Hmmm, well, that is certainly disappointing. I guess my only real option is to save the actual dialog file to the gm game/safe directory. I was hoping to avoid that as these files can get quite large.

Thanks!
 

BlueBurn

Member
Yeah it's windows only, and functions get_save_filename/get_open_filename are windows only too, so i guess you need to find some other solution.
 

BlueBurn

Member
Yeah that's also the solution, but if you just need to read (and not write) from the same directory as the executable file, there should be no problem and for example this: file_exists("yourfile.dat"); should work fine.
 
Yeah that's also the solution, but if you just need to read (and not write) from the same directory as the executable file, there should be no problem and for example this: file_exists("yourfile.dat"); should work fine.
Hmm, I tried this already, file_exists returns false, even with my file to be read and the executable both living in the same directory
 

kburkhart84

Firehammer Games
I guess the best solution would be to learn a little C++, and create an extension. Extensions can actually be created to support multiple platforms all at once, though you would have to write different code accordingly. The function would call whichever call is needed based on the OS, so on windows it would grab the DLL, on Linux the alternate, Mac, the same. It takes some work but GMStudio is capable of this.

I would like them to allow us to turn off the sandboxing. Maybe they will have it be optional in a future release.
 

BlueBurn

Member
Hmm, I tried this already, file_exists returns false, even with my file to be read and the executable both living in the same directory
Well, It's because you need to extract the runner exe from the compressed exe or better select "Compressed Applications zip" when you are creating the executable.

I guess the best solution would be to learn a little C++, and create an extension. Extensions can actually be created to support multiple platforms all at once, though you would have to write different code accordingly. The function would call whichever call is needed based on the OS, so on windows it would grab the DLL, on Linux the alternate, Mac, the same. It takes some work but GMStudio is capable of this.

I would like them to allow us to turn off the sandboxing. Maybe they will have it be optional in a future release.
Yeah of course it is possible, but so far just no one did that. (It would be also possible do that for android as well).
 
I guess the best solution would be to learn a little C++, and create an extension. Extensions can actually be created to support multiple platforms all at once, though you would have to write different code accordingly. The function would call whichever call is needed based on the OS, so on windows it would grab the DLL, on Linux the alternate, Mac, the same. It takes some work but GMStudio is capable of this.

I would like them to allow us to turn off the sandboxing. Maybe they will have it be optional in a future release.
Yeah, I was thinking of that, just didn't want to have to mess with it. This is probably the route I'll take in future, but I seem to have it working by saving directly to the sandboxed directory from java.

Well, It's because you need to extract the runner exe from the compressed exe or better select "Compressed Applications zip" when you are creating the executable..
Ah! I gotcha! I have it working already by saving to the sandboxed folder, but if it becomes a problem in future ill remember this. Thanks for all the help!
 

Samuel Venable

Time Killer
Don't know if you still need this but anyway my extension works on Windows and Linux, (you'll need to compile from source code for Mac support, but it should work on there too). :)

Edit:

Woah, I could've sworn the date on that post said July 2017. I just bumped a year-old thread. lol my bad...
 
Last edited:
Top