TagSpaces is an offline, open source, document manager with tagging support
getFileContent implementation node-webkit
Borislav Sapundzhieve1a8eeef5ec5
diff --git a/data/node-webkit/node-webkit.api.js b/data/node-webkit/node-webkit.api.jsindex 503a0e948..9495ac04f 100644--- a/data/node-webkit/node-webkit.api.js+++ b/data/node-webkit/node-webkit.api.js@@ -637,10 +637,9 @@ define(function(require, exports, module) {fsWatcher = fs.watch(dirPath, { persistent: true, recursive: false }, listener);};- function getFile(filePath, result, fail) {+ function getFile(fileURL, result, fail) {var xhr = new XMLHttpRequest();- var fileURL = "file://" + filePath;xhr.open("GET", fileURL, true);xhr.responseType = "arraybuffer";xhr.onload = function() {@@ -653,6 +652,26 @@ define(function(require, exports, module) {xhr.send();}+ function getFileContent(fullPath, resutl, error) {++ if(fullPath.indexOf("file://") === -1) {+ fullPath = "file://" + fullPath;+ }++ getFile(filePath, function(file) {+ var reader = new FileReader();+ reader.onerror = function(){+ error(reader.error);+ };++ reader.onload = function() {+ result(reader.result);+ };++ reader.readAsArrayBuffer(file);+ }, error);+ }+exports.createDirectory = createDirectory;exports.renameDirectory = renameDirectory;exports.renameFile = renameFile;@@ -679,4 +698,5 @@ define(function(require, exports, module) {exports.focusWindow = focusWindow;exports.showMainWindow = showMainWindow;exports.getFile = getFile;+ exports.getFileContent = getFileContent;});