"use strict";
const tauri = window.__TAURI__;
StorageManager.fileDirectoryPath = async function () {
// Old code
// const path = require('path');
// const base = path.dirname(process.mainModule.filename);
// return path.join(base, 'save/');
const base = await tauri.path.dirname(process.mainModule.filename);
return await tauri.path.join(base, 'save/');
};
})();```
#Should i replace the deprecated process.mainModule.filename with which Tauri api?
1 messages · Page 1 of 1 (latest)
If I understand your code correctly, you want to find the file that is currently being executed and then return it's sibling save directory?
Tauri's JS files are bundled into the executable so there's no way to replicate this exactly. It's also not recommended to write to the install directory as it is typically a read-only directory.
resourceDir() is usually reserved for Tauri's automatically bundled files (https://tauri.app/v1/guides/building/resources).
that kinda depends on what you're trying to store
which
Returns the path to the suggested directory for your app's data files
hm
I feel like you'd want to bundle a bunch of these using whatever web app bundler you have
it's in the src folder the print above
i'm still maintaining compatibility with nw.js with this structure
okay
I think
I found what you should be doing
one: check out https://tauri.app/v1/api/config/#bundleconfig
it has a "resources" key which lets you define arbitrary paths to be included in your bundle by tauri
then two
will resolve a relative path to your bundled resources
Keep in mind that bundling the files into resources will make them accessible on the filesystem. Tauri doesn't provide much protection for your JS code to begin with but you still have to run it through a program like strings to get any of it.
NW.js seems to provide some kind of protection mechanism but it doesn't sound like it's particularly secure from their docs.
you're not supposed to bundle javascript files as a resource
my assumption was that this is about things like images, sound, etc
@proud reef what do you keen in save/?
if this is a game I'd assume the user's savestate
which probably is more fit for appDataDir or appLocalDataDir
It's a RPG Maker MZ game, originally created using pixi.js and nw.js, i was using electron to bundle my game but the size was 1.1 gb compared to tauri's 600 mb so i decided to give it a try, the save folder is the only incompatibility so far
I'm not particularly familiar with RPG Maker's expectations of file locations. Are you able to place it anywhere you want or does it have to be in the install directory?
seems to store save folder locally in game folder if using nw.js but if running in browser it appears to be cached
It's a good engine to make a quick RPG prototype or a fangame and it comes with a lot already coded if you know some JS you can easily extend the features but between it and Godot the latter is much better
It sounds like RPG Maker MZ can read it from anywhere it wants.