fix stuff

This commit is contained in:
Xuan Sang LE 2018-02-13 20:27:41 +01:00
parent 133b7512fa
commit 64238fffbb
3 changed files with 27 additions and 21 deletions

View File

@ -8,6 +8,7 @@ coffees= src/core/core.coffee\
src/core/api.coffee\ src/core/api.coffee\
src/core/handlers/RemoteHandler.coffee\ src/core/handlers/RemoteHandler.coffee\
src/core/vfs.coffee\ src/core/vfs.coffee\
src/core/vfs/GoogleDriveHandler.coffee\
src/core/db.coffee\ src/core/db.coffee\
src/core/gui.coffee\ src/core/gui.coffee\
src/core/BaseModel.coffee\ src/core/BaseModel.coffee\

View File

@ -11,16 +11,23 @@ String.prototype.asBase64 = () ->
) )
String.prototype.asFileHandler = () -> String.prototype.asFileHandler = () ->
list = this.split ":///" list = @split ":///"
switch list[0] handlers = _API.VFS.findHandlers list[0]
when "app" if not handlers or handlers.length is 0
return new ApplicationHandler(this) _courrier.osfail "VFS unknown handler: #{@}", (_API.throwe "OS.VFS"), @
else return null
return new RemoteFileHandler(this) return new handlers[0](@)
this.OS.API.VFS = {} this.OS.API.VFS =
handlers: { }
register: ( protos, cls ) ->
return self.OS.API.VFS.handlers[protos] = cls # if typeof protos is "string"
#_API.VFS.handlers[v] = cls for v in protos
findHandlers: (proto) ->
l = (v for k, v of _API.VFS.handlers when proto.match (new RegExp k , "g"))
return l
class BasicFileHandler class BaseFileHandler
constructor: (path) -> constructor: (path) ->
@dirty = false @dirty = false
@cache = undefined @cache = undefined
@ -120,10 +127,10 @@ class BasicFileHandler
return _courrier.osfail "VFS unknown action: #{n}", (_API.throwe "OS.VFS"), n return _courrier.osfail "VFS unknown action: #{n}", (_API.throwe "OS.VFS"), n
# now export the class # now export the class
self.OS.API.VFS.BasicFileHandler = BasicFileHandler self.OS.API.VFS.BaseFileHandler = BaseFileHandler
# Remote file handle # Remote file handle
class RemoteFileHandler extends self.OS.API.VFS.BasicFileHandler class RemoteFileHandler extends self.OS.API.VFS.BaseFileHandler
constructor: (path) -> constructor: (path) ->
super path super path
@ -157,10 +164,10 @@ class RemoteFileHandler extends self.OS.API.VFS.BasicFileHandler
else else
return _courrier.osfail "VFS unknown action: #{n}", (_API.throwe "OS.VFS"), n return _courrier.osfail "VFS unknown action: #{n}", (_API.throwe "OS.VFS"), n
self.OS.API.VFS.RemoteFileHandler = RemoteFileHandler self.OS.API.VFS.register "^(home|shared|desktop|os)$", RemoteFileHandler
# Application Handler # Application Handler
class ApplicationHandler extends self.OS.API.VFS.BasicFileHandler class ApplicationHandler extends self.OS.API.VFS.BaseFileHandler
constructor: (path) -> constructor: (path) ->
super path super path
@info = _OS.setting.system.packages[@basename] if @basename @info = _OS.setting.system.packages[@basename] if @basename
@ -199,12 +206,4 @@ class ApplicationHandler extends self.OS.API.VFS.BasicFileHandler
else else
return _courrier.osfail "VFS unknown action: #{n}", (_API.throwe "OS.VFS"), n return _courrier.osfail "VFS unknown action: #{n}", (_API.throwe "OS.VFS"), n
self.OS.API.VFS.ApplicationHandler = ApplicationHandler self.OS.API.VFS.register "^app$", ApplicationHandler
# GoogleDrive File Handler
class GoogleDriveHandler extends self.OS.API.VFS.BasicFileHandler
constructor: (path) ->
super path
self.OS.API.VFS.GoogleDriveHandler = GoogleDriveHandler

View File

@ -0,0 +1,6 @@
# GoogleDrive File Handler
class GoogleDriveHandler extends this.OS.API.VFS.BaseFileHandler
constructor: (path) ->
super path
self.OS.API.VFS.register "^gdv$", GoogleDriveHandler