-
-
Notifications
You must be signed in to change notification settings - Fork 423
Expand file tree
/
Copy pathasync.lua
More file actions
50 lines (42 loc) · 1.13 KB
/
async.lua
File metadata and controls
50 lines (42 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
local reader = ls.async.create('afs-reader', 2, 'filesystem.async-worker', true)
local writer = ls.async.create('afs-writer', 1, 'filesystem.async-worker', true)
---@class AsyncFileSystem: FileSystem
ls.afs = Class('AsyncFileSystem', 'FileSystem')
ls.afs.mode = 'async'
---@async
---@param uri Uri
---@return Uri[]?
function ls.afs.getChilds(uri)
return reader:awaitRequest('getChilds', { uri })
end
---@async
---@param uri Uri
---@return 'file'|'directory'|'symlink'|nil
function ls.afs.getTypeWithSymlink(uri)
return reader:awaitRequest('getTypeWithSymlink', { uri })
end
---@async
---@param uri Uri
---@return 'file'|'directory'|nil
function ls.afs.getType(uri)
return reader:awaitRequest('getType', { uri })
end
---@async
---@param uri Uri
---@return string?
function ls.afs.read(uri)
return reader:awaitRequest('read', { uri })
end
---@async
---@param uri Uri
---@param content string
---@return boolean
function ls.afs.write(uri, content)
return writer:awaitRequest('write', { uri, content })
end
---@async
---@param uri Uri
---@return boolean
function ls.afs.remove(uri)
return writer:awaitRequest('remove', { uri })
end