Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (os_type == os_macosx) {
- /*
- This function will set the working directory to the app bundle's Resources folder
- like GM4Mac 7.5, GMStudio 1.4, GMS 2.x and most Mac apps do, if the executable is in
- an app bundle. If the executable is not in an app bundle, use the getcwd function
- ONLY use get_working_directory() for loading read-only included files! When SAVING, use game_save_id
- *_bname = base name - removes the full path from the string leaving just the file or folder name
- *_dname = directory name - removes final slash and base name from full path to file or folder name
- *_pname = path name - removes the base name from a full path while keeping the dir and final slash
- *_ename = extension name - includes everything in bname at and following the period if one exists
- */
- var success = false;
- var exe_pname = get_program_directory(); // = "/Path/To/YourAppBundle.app/Contents/MacOS/";
- var macos_dname = filename_dir(exe_pname); // = "/Path/To/YourAppBundle.app/Contents/MacOS";
- var macos_bname = filename_name(macos_dname); // = "MacOS";
- var contents_dname = filename_dir(macos_dname); // = "/Path/To/YourAppBundle.app/Contents";
- var contents_bname = filename_name(contents_dname); // = "Contents";
- var app_dname = filename_dir(contents_dname); // = "/Path/To/YourAppBundle.app";
- var app_ename = filename_ext(app_dname); // = ".app";
- var contents_pname = filename_path(macos_dname); // = "/Path/To/YourAppBundle.app/Contents/";
- var resources_pname = contents_pname + "Resources/"; // = "/Path/To/YourAppBundle.app/Contents/Resources/";
- // if "/Path/To/YourAppBundle.app/Contents/MacOS/YourExe" and "/Path/To/YourAppBundle.app/Contents/Resources/" exists
- if (macos_bname == "MacOS" && contents_bname == "Contents" && app_ename == ".app" && directory_exists(resources_pname)) {
- // set working directory to "/Path/To/YourAppBundle.app/Contents/Resources/" and allow loading normal included files
- success = set_working_directory(resources_pname);
- }
- /* if (success) show_message("Success!"); else show_message("Failure!");
- get_string_async("The current value of working_directory equals:", get_working_directory()); */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement