Workspaces / document saving/opening

This commit is contained in:
2023-12-25 14:41:15 -05:00
parent eb0077c849
commit 030f0e6438
7 changed files with 215 additions and 73 deletions

View File

@@ -1,16 +1,15 @@
export default {
async access(path) {
try {
await Neutralino.filesystem.getStats(path)
return
} catch(err) {
if(err.name = 'NE_FS_NOPATHE') {
return false
} else {
throw err
}
}
},
{
let userHome
const handleNeutralinoError = err => {
throw new Error(err.code + ': ' + err.message)
}
window.Platform = {
//
// Paths
//
dirname(path) {
let index = path.lastIndexOf('/')
@@ -28,6 +27,51 @@ export default {
let filename = this.filename(path)
let index = filename.lastIndexOf('.')
return index === -1 ? '' : path.slice(index + 1)
}
return index === -1 ? '' : filename.slice(index + 1)
},
join(...args) {
return args.join('/')
},
// TODO: support non-posix
absolute(path) {
return path.charAt(0) === '/'
},
//
// FS
//
async access(path) {
try {
await Neutralino.filesystem.getStats(path)
return
} catch(err) {
if(err.name = 'NE_FS_NOPATHE') {
return false
} else {
throw err
}
}
},
writeText(path, content) {
return Neutralino.filesystem.writeFile(path, content)
.catch(handleNeutralinoError)
},
readText(path) {
return Neutralino.filesystem.readFile(path)
.catch(handleNeutralinoError)
},
//
// OS
//
async getHome() {
return userHome ?? (userHome = await Neutralino.os.getEnv('HOME'))
},
}
}