fix file reader

This commit is contained in:
Xuan Sang LE 2018-03-01 19:33:36 +01:00
parent 080e2c95ae
commit 7911f259b1
3 changed files with 7 additions and 6 deletions

View File

@ -151,7 +151,7 @@ class RemoteFileHandler extends self.OS.API.VFS.BaseFileHandler
when "read"
return _API.handler.scandir @path, f if @info.type is "dir"
#read the file
return _API.handler.fileblob @path, f if p is "blob"
return _API.handler.fileblob @path, f if p is "binary"
_API.handler.readfile @path, f, if p then p else "text"
when "mk"
return f { error: "#{@path} is not a directory" } if @info.type is "file"
@ -221,7 +221,7 @@ class ApplicationHandler extends self.OS.API.VFS.BaseFileHandler
self.OS.API.VFS.register "^app$", ApplicationHandler
class BlobFileHandler extends self.OS.API.VFS.BaseFileHandler
class BufferFileHandler extends self.OS.API.VFS.BaseFileHandler
constructor: (path, mime, data) ->
super path
@cache = data if data
@ -269,7 +269,7 @@ class BlobFileHandler extends self.OS.API.VFS.BaseFileHandler
else
return _courrier.osfail "VFS unknown action: #{n}", (_API.throwe "OS.VFS"), n
self.OS.API.VFS.register "^blob$", BlobFileHandler
self.OS.API.VFS.register "^mem$", BufferFileHandler
class SharedFileHandler extends self.OS.API.VFS.BaseFileHandler
constructor: (path) ->
@ -284,6 +284,7 @@ class SharedFileHandler extends self.OS.API.VFS.BaseFileHandler
when "read"
return _API.get "#{_API.handler.shared}/all", f, ((e, s)->) if @isRoot()
#read the file
return _API.handler.fileblob @path, f if p is "binary"
_API.handler.readfile @path, f, if p then p else "text"
when "mk"
return

View File

@ -161,7 +161,7 @@ class GoogleDriveHandler extends this.OS.API.VFS.BaseFileHandler
}
.then (r) ->
_API.loaded q, "OK"
return f r.body unless p is "blob"
return f r.body unless p is "binary"
bytes = []
for i in [0..(r.body.length - 1)]
bytes.push r.body.charCodeAt i

View File

@ -67,7 +67,7 @@ class Preview extends this.OS.GUI.BaseApplication
.catch (err) ->
me.error "Cannot render the PDF file"
me._api.loaded q, "FAIL"
, "blob"
, "binary"
renderImage: (file) ->
me = @
@ -88,7 +88,7 @@ class Preview extends this.OS.GUI.BaseApplication
console.log canvas.width, canvas.height
context.drawImage img, 0, 0
me.setStatus "#{file.info.name} (#{file.info.size} Kb) - #{img.width}x#{img.height}"
, "blob"
, "binary"
menu: () ->
me = @