Code mirror plugin lsp interface (#1444)
* better named dirs Signed-off-by: Jess Frazelle <github@jessfraz.com> * move some stuff around Signed-off-by: Jess Frazelle <github@jessfraz.com> * more logging Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * less logging Signed-off-by: Jess Frazelle <github@jessfraz.com> * add fs in Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * file reader Signed-off-by: Jess Frazelle <github@jessfraz.com> * workspace Signed-off-by: Jess Frazelle <github@jessfraz.com> * start of workspace folders Signed-off-by: Jess Frazelle <github@jessfraz.com> * start of workspace folders Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanup workspace folders Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanup logs Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
@ -1,4 +1,8 @@
|
||||
import { readBinaryFile, exists as tauriExists } from '@tauri-apps/api/fs'
|
||||
import {
|
||||
readDir,
|
||||
readBinaryFile,
|
||||
exists as tauriExists,
|
||||
} from '@tauri-apps/api/fs'
|
||||
import { isTauri } from 'lib/isTauri'
|
||||
import { join } from '@tauri-apps/api/path'
|
||||
|
||||
@ -53,6 +57,30 @@ class FileSystemManager {
|
||||
return tauriExists(file)
|
||||
})
|
||||
}
|
||||
|
||||
getAllFiles(path: string): Promise<string[] | void> {
|
||||
// Using local file system only works from Tauri.
|
||||
if (!isTauri()) {
|
||||
throw new Error(
|
||||
'This function can only be called from a Tauri application'
|
||||
)
|
||||
}
|
||||
|
||||
return join(this.dir, path)
|
||||
.catch((error) => {
|
||||
throw new Error(`Error joining dir: ${error}`)
|
||||
})
|
||||
.then((p) => {
|
||||
readDir(p, { recursive: true })
|
||||
.catch((error) => {
|
||||
throw new Error(`Error reading dir: ${error}`)
|
||||
})
|
||||
|
||||
.then((files) => {
|
||||
return files.map((file) => file.path)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export const fileSystemManager = new FileSystemManager()
|
||||
|
Reference in New Issue
Block a user