mirror of
https://github.com/lxsang/antos-frontend.git
synced 2025-02-22 18:02:47 +01:00
fix file reader
This commit is contained in:
parent
080e2c95ae
commit
7911f259b1
@ -151,7 +151,7 @@ class RemoteFileHandler extends self.OS.API.VFS.BaseFileHandler
|
|||||||
when "read"
|
when "read"
|
||||||
return _API.handler.scandir @path, f if @info.type is "dir"
|
return _API.handler.scandir @path, f if @info.type is "dir"
|
||||||
#read the file
|
#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"
|
_API.handler.readfile @path, f, if p then p else "text"
|
||||||
when "mk"
|
when "mk"
|
||||||
return f { error: "#{@path} is not a directory" } if @info.type is "file"
|
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
|
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) ->
|
constructor: (path, mime, data) ->
|
||||||
super path
|
super path
|
||||||
@cache = data if data
|
@cache = data if data
|
||||||
@ -269,7 +269,7 @@ class BlobFileHandler extends self.OS.API.VFS.BaseFileHandler
|
|||||||
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.register "^blob$", BlobFileHandler
|
self.OS.API.VFS.register "^mem$", BufferFileHandler
|
||||||
|
|
||||||
class SharedFileHandler extends self.OS.API.VFS.BaseFileHandler
|
class SharedFileHandler extends self.OS.API.VFS.BaseFileHandler
|
||||||
constructor: (path) ->
|
constructor: (path) ->
|
||||||
@ -284,6 +284,7 @@ class SharedFileHandler extends self.OS.API.VFS.BaseFileHandler
|
|||||||
when "read"
|
when "read"
|
||||||
return _API.get "#{_API.handler.shared}/all", f, ((e, s)->) if @isRoot()
|
return _API.get "#{_API.handler.shared}/all", f, ((e, s)->) if @isRoot()
|
||||||
#read the file
|
#read the file
|
||||||
|
return _API.handler.fileblob @path, f if p is "binary"
|
||||||
_API.handler.readfile @path, f, if p then p else "text"
|
_API.handler.readfile @path, f, if p then p else "text"
|
||||||
when "mk"
|
when "mk"
|
||||||
return
|
return
|
||||||
|
@ -161,7 +161,7 @@ class GoogleDriveHandler extends this.OS.API.VFS.BaseFileHandler
|
|||||||
}
|
}
|
||||||
.then (r) ->
|
.then (r) ->
|
||||||
_API.loaded q, "OK"
|
_API.loaded q, "OK"
|
||||||
return f r.body unless p is "blob"
|
return f r.body unless p is "binary"
|
||||||
bytes = []
|
bytes = []
|
||||||
for i in [0..(r.body.length - 1)]
|
for i in [0..(r.body.length - 1)]
|
||||||
bytes.push r.body.charCodeAt i
|
bytes.push r.body.charCodeAt i
|
||||||
|
@ -67,7 +67,7 @@ class Preview extends this.OS.GUI.BaseApplication
|
|||||||
.catch (err) ->
|
.catch (err) ->
|
||||||
me.error "Cannot render the PDF file"
|
me.error "Cannot render the PDF file"
|
||||||
me._api.loaded q, "FAIL"
|
me._api.loaded q, "FAIL"
|
||||||
, "blob"
|
, "binary"
|
||||||
|
|
||||||
renderImage: (file) ->
|
renderImage: (file) ->
|
||||||
me = @
|
me = @
|
||||||
@ -88,7 +88,7 @@ class Preview extends this.OS.GUI.BaseApplication
|
|||||||
console.log canvas.width, canvas.height
|
console.log canvas.width, canvas.height
|
||||||
context.drawImage img, 0, 0
|
context.drawImage img, 0, 0
|
||||||
me.setStatus "#{file.info.name} (#{file.info.size} Kb) - #{img.width}x#{img.height}"
|
me.setStatus "#{file.info.name} (#{file.info.size} Kb) - #{img.width}x#{img.height}"
|
||||||
, "blob"
|
, "binary"
|
||||||
|
|
||||||
menu: () ->
|
menu: () ->
|
||||||
me = @
|
me = @
|
||||||
|
Loading…
x
Reference in New Issue
Block a user