Resolve special char "~" on Dialog Box's paths. "~" will be resolved to the user's home directory.

Example: Open a Dialog Box on the user's Documents folder with "~/Documents"
This commit is contained in:
Pixelnerve 2020-03-31 23:41:35 +02:00
parent 06e64e9c5b
commit fa59f60973

View file

@ -417,7 +417,16 @@ module.exports = {
var p = process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME']
if (data.path) p = path.resolve(...data.path)
if (data.path) {
// Resolve '~' to user's home directory
if (data.path[0].startsWith('~')) {
p = data.path[0].replace( "~", p );
}
else {
p = path.resolve(...data.path)
}
//console.log(`Resolved path: ${p}`);
}
var root = settings.read('remote-root')
if (root && !p.includes(root)) p = root