|
|
|
@ -119,39 +119,36 @@ class FileManager { |
|
|
|
|
return path ? path[1] : null |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getCurrentFile (cb) { |
|
|
|
|
var path = this.currentFile() |
|
|
|
|
if (!path) { |
|
|
|
|
cb('no file selected') |
|
|
|
|
} else { |
|
|
|
|
cb(null, path) |
|
|
|
|
} |
|
|
|
|
async getCurrentFile () { |
|
|
|
|
const path = this.currentFile() |
|
|
|
|
if (!path) throw 'no file selected' |
|
|
|
|
return path |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getFile (path, cb) { |
|
|
|
|
var provider = this.fileProviderOf(path) |
|
|
|
|
if (provider) { |
|
|
|
|
// TODO add approval to user for external plugin to get the content of the given `path`
|
|
|
|
|
provider.get(path, (error, content) => { |
|
|
|
|
cb(error, content) |
|
|
|
|
getFile (path) { |
|
|
|
|
const provider = this.fileProviderOf(path) |
|
|
|
|
if (!provider) throw new Error(`${path} not available`) |
|
|
|
|
// TODO: change provider to Promise
|
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
provider.get(path, (err, content) => { |
|
|
|
|
if (err) reject(err) |
|
|
|
|
resolve(content) |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
cb(path + ' not available') |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
setFile (path, content, cb) { |
|
|
|
|
var provider = this.fileProviderOf(path) |
|
|
|
|
if (provider) { |
|
|
|
|
// TODO add approval to user for external plugin to set the content of the given `path`
|
|
|
|
|
setFile (path, content) { |
|
|
|
|
const provider = this.fileProviderOf(path) |
|
|
|
|
if (!provider) throw new Error(`${path} not availble`) |
|
|
|
|
// TODO : Add permission
|
|
|
|
|
// TODO : Change Provider to Promise
|
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
provider.set(path, content, (error) => { |
|
|
|
|
if (error) return cb(error) |
|
|
|
|
if (error) reject(error) |
|
|
|
|
this.syncEditor(path) |
|
|
|
|
cb() |
|
|
|
|
resolve(true) |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
cb(path + ' not available') |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
removeTabsOf (provider) { |
|
|
|
|