Custom Save Path in Documents/namegame/gamesave

Hello there, i have a problem with a deplyed MAC or PC (in enigma toolbox) compiled version.
Save won't work.
Reading around i have find some plugins for custom game save path but they won't work too, is a permission problems
and i have also try to change CHMOD to 777 but nothing.

My game is rpg_core.js v1.5.1

For now the only solution that i find is this plugin:

Code:
StorageManager.localFileDirectoryPath = function() {
    var path = require('path');

    var base = path.dirname(process.mainModule.filename);
 
  var previousFolders = 4;
    for(var i = 0; i < previousFolders; i++){
      base = path.dirname(base);
  }     
 
 
  return path.join(base, 'gamesave/');
};

This move gamesave folder outside the game.app but it works only if you put the app in the desktop.
There's a way to change this plugin to absolute path like (documents/username/gamename/gamesave) for MAC and PC?
Thank you
Code:
var os = require("os");
var fs = require("fs");
var homedir = os.homedir();
if (homedir.readdirSync().indexOf("gamesaves") < 0) fs.mkdirSync(homedir + "gamesaves");
return homedir + "gamesaves/";

However, by default game files, on newer windows platforms, are saved into C:\Users\Username\Appdata\Roaming\ if I remember correctly. You can just hard input it there. For example:

Code:
var fs = require ("fs");
var saveText = "jjdijsmikekdijmdkdjnekkd";
fs.writeFileSync ("C:/testFile.txt", saveText);
writes the save text directly in your C directory. Where the game's directory is located, is irrelevant.

On Linux it would be
Code:
fs.writeFileSync ("~/Documents/testFile.txt, saveText) instead, because on linux ~ means user's home directory.
thank you @Poryg anyway i think the main problem of a compiled MAC OS app, is just the permissions.
Without any plugin i got the attacched error.
How to set a CHMOD 777 to entire game app and subfolders?
On mac usually there's the option on file info to do that, but it can't let me set subfolders.
Thanks, i just want to understand this issue.
I don't know how it works on mac, but in regards to linux there's usually StackOverflow. Probably a better shot asking there if this doesn't work.
https://stackoverflow.com/questions/8328481/chmod-777-to-a-folder-and-all-contents
thanks

Original thread: https://forums.rpgmakerweb.com/threads/custom-save-path-in-documents-namegame-gamesave.109490/