How to access %APPDATA%?

Discussion in 'Javascript/Plugin Support' started by Cinnamon, Jan 20, 2016.

Thread Status:
Not open for further replies.
  1. Cinnamon

    Cinnamon Veteran Veteran

    Messages:
    605
    Likes Received:
    209
    First Language:
    English
    If the game is located in ProgramFiles and attempts to create a save file or folder, it'll throw an EPERM Operation Not Permitted error. It is fixed by right-clicking and running as administrator, but it'd be impractical to request all gamers to do that.


    What's a way around this?


    I'm thinking of simply saving everything in %APPDATA%, like XP and VX did, but how can this be done?


    I guess this code would have to refer to %APPDATA% instead of the same folder as the game:

    Code:
    StorageManager.localFileDirectoryPath = function() {
    	    var path = window.location.pathname.replace(/(\/www|)\/[^\/]*$/, '/save/');
    	    if (path.match(/^\/([A-Z]\:)/)) {
    	        path = path.slice(1);
    	    }
    	    return decodeURIComponent(path);
    	};



    Thanks! :)
     
    #1
  2. Cinnamon

    Cinnamon Veteran Veteran

    Messages:
    605
    Likes Received:
    209
    First Language:
    English
    Nvm, fixed it:
     


        //var path = window.location.pathname.replace(/(\/www|)\/[^\/]*$/, '/save/');
        var path = process.env.APPDATA + '/YourGame Saves/'
     
    #2
    Quxios and Shaz like this.
  3. SimProse

    SimProse Veteran Veteran

    Messages:
    363
    Likes Received:
    197
    Location:
    United States
    First Language:
    English
    How do I do this with 1.5.2 of MV? The lines don't read the same way, and my deployed game will not save at all, giving me those EPERM errors.
    The current lines:
    Code:
    StorageManager.localFileDirectoryPath = function() {
        var path = require('path');
    
        var base = path.dirname(process.mainModule.filename);
        return path.join(base, 'save/');
    Thanks!
     
    #3
  4. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,612
    Likes Received:
    10,514
    First Language:
    English
    Primarily Uses:
    RMVXA

    SimProse, please refrain from necro-posting in a thread. Necro-posting is posting in a thread that has not had posting activity in over 30 days. You can review our forum rules here. Thank you.


    I suggest you start a new thread, as the cause of your problem is clearly different from that of the OP.

    Closing this.

     
    #4
Thread Status:
Not open for further replies.

Share This Page