VFS(cont)

This commit is contained in:
Xuan Sang LE 2018-01-24 01:03:14 +01:00
parent a70f52f965
commit dfbeb16601
6 changed files with 34 additions and 19 deletions

View File

@ -9,12 +9,12 @@ class BaseModel
@setting = _OS.setting.applications[@name]
@dialog = undefined
@subscribe "appregistry"
,(m)->
, ( m ) ->
me.applySetting m.data.m if (m.name is me.name)
registry: (k,v) ->
registry: (k, v) ->
@setting[k] = v
@publish "appregistry",k
@publish "appregistry", k
render: (p) ->
_GUI.loadScheme p, @, @host
@ -70,6 +70,8 @@ class BaseModel
fail: (m) ->
@publish "fail", m
throwe: () ->
@_api.throwe @name
find: (id) -> ($ "[data-id='#{id}']", @scheme)[0] if @scheme

View File

@ -54,4 +54,13 @@ self.OS.API =
resource: (r, c, f) ->
path = "resources/#{r}"
_API.get path, c, f
throwe: (n) ->
err = undefined
try
throw new Error(n)
catch e
err = e
return "" if not err
return err.stack

View File

@ -37,7 +37,7 @@ self.OS.GUI =
app = arr[0]
return _PM.createProcess srv, _OS.APP[srv] if _OS.APP[srv]
_GUI.loadApp app,
(a)->
(a) ->
return _PM.createProcess srv, _OS.APP[srv] if _OS.APP[srv]
(e, s) ->
_courrier.trigger "srvroutineready", srv
@ -49,7 +49,7 @@ self.OS.GUI =
_OS.APP[app] = undefined
_GUI.launch app, args
loadApp:(app, ok, err) ->
loadApp: (app, ok, err) ->
path = "packages/#{app}/"
_API.script path + "main.js",
(d) ->

View File

@ -2,13 +2,18 @@ self.OS.API.handler =
scandir: (p, c ) ->
path = "lua-api/fs/scandir"
_API.post path, { path: p }, c, (e, s) ->
_courrier.osfail "Fail to scan directory: #{path}", e, s
_courrier.osfail "Fail to scan directory: #{p}", e, s
fileinfo: (p, c) ->
path = "lua-api/fs/fileinfo"
_API.post path, { path: p }, c, (e, s) ->
_courrier.osfail "Fail to get file metadata: #{path}", e, s
_courrier.osfail "Fail to get file metadata: #{p}", e, s
readfile: (p, c) ->
path = "lua-api/fs/get/"
_API.get path + p, c, (e, s) ->
_courrier.osfail "Fail to read file: #{p}",e , s
scanapp: (p, c ) ->
path = "lua-api/system/application"
auth: (c) ->

View File

@ -39,21 +39,21 @@ class BasicFileHandler
return @ if @isRoot()
(@protocol + ":///" + (@genealogy.slice 0 , @genealogy.length - 1).join "/").asFileHandler()
onready: (f, e) ->
onready: (f) ->
# read meta data
return f() if @ready
me = @
me.meta (d) ->
return e d.error if d.error
return _courrier.osfail d.error, (_API.throwe "OS.VFS"), d.error if d.error
me.meta = d.result
me.ready = true
f()
#public interface for all action on file
do: (a, f, e) ->
return e "Action #{a} not found" if not @[a]
do: (a, f) ->
return _courrier.osfail "VFS unknown action: #{a}", (_API.throwe "OS.VFS"), a if not @[a]
me = @
@onready (() -> me[a] f), e
@onready (() -> me[a] f)
# methods implemented by subclasses used as private methods
@ -66,8 +66,6 @@ class BasicFileHandler
remove: (f) ->
execute: (f) ->
ls: (f) ->
mk: (f) ->
@ -82,9 +80,10 @@ class RemoteFileHandler extends self.OS.API.VFS.BasicFileHandler
meta: (f) ->
_API.handler.fileinfo @path, f
ls: (f) ->
return f(@) if @meta.type is "file"
_API.handler.scandir @path, f
read: (f) ->
return _API.handler.scandir @path, f if @meta.type is "dir"
#read the file
_API.handler.readfile @path, f
self.OS.API.VFS.RemoteFileHandler = RemoteFileHandler

View File

@ -55,7 +55,7 @@ class PushNotification extends this.OS.GUI.BaseService
pushout: (s, o, mfeed) ->
d = {
text: "[#{s}] #{o.name} (#{o.id}): #{o.data.m}",
text: "[#{s}] #{o.name} (#{o.id}): #{o.data.m} : #{o.data.e}",
icon: o.data.icon,
iconclass: o.data.iconclass,
closable: true }