Workspaces / document saving/opening
This commit is contained in:
@@ -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'))
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user