TagSpaces is an offline, open source, document manager with tagging support
chrome ioapi made windows specific
uggrockf09b20816e41
diff --git a/data/js/ioapi.chrome.js b/data/js/ioapi.chrome.jsindex d6b10590a..6c61c411c 100644--- a/data/js/ioapi.chrome.js+++ b/data/js/ioapi.chrome.js@@ -11,7 +11,7 @@ define(function(require, exports, module) {var TSPOSTIO = require("tspostioapi");/**-API of npapifileioforchrome:+IO-APIbool createDirectory(std::string path);bool saveBlobToFile(std::string path, FB::JSObjectPtr dataArray);@@ -28,13 +28,9 @@ API of npapifileioforchrome:std::string getChromeDataDir(std::string version);bool NPAPIFileIOforChromeAPI::renameFile(std::string oldPath, std::string newPath);- std::time_t NPAPIFileIOforChromeAPI::lastDateModified(std::string strPath);--Still Missing:- renameFile real one- openDirectory- fileSize buggy in a loop- lastModified datetime completely missing+ std::time_t NPAPIFileIOforChromeAPI::getFileLastDateModified(std::string strPath);+ void launchFolder(std::string path); -- not implemented yet+*/var plugin = document.createElement("embed");@@ -58,7 +54,9 @@ Still Missing:var lastDateModified = 0;if(!isDir) {fileSize = nativeIO.getFileSize(path);- //lastDateModified = new Date(nativeIO.lastDateModified(path)*1000);+ if(isWin) {+ lastDateModified = new Date(nativeIO.getFileLastDateModified(path)*1000);+ }}index.push({"name": dirList[i],@@ -93,7 +91,9 @@ Still Missing:var lastDateModified = 0;if (!isDir) {fileSize = nativeIO.getFileSize(path);- //lastDateModified = new Date(nativeIO.lastDateModified(path)*1000);+ if(isWin) {+ lastDateModified = new Date(nativeIO.getFileLastDateModified(path)*1000);+ }tree["children"].push({"name": dirList[i],"type": "file",@@ -137,7 +137,7 @@ Still Missing:console.log("AJAX failed "+data);});- }+ };exports.loadTextFile = function(filePath) {console.log("Loading file: "+filePath);@@ -155,12 +155,12 @@ Still Missing:var reader = new FileReader();reader.onload = function (e) {TSPOSTIO.loadTextFile(e.target.result);- }+ };reader.readAsText(b);} else {console.error("File does not exists...");}- }+ };exports.listDirectory = function(dirPath) {console.log("Listing directory: "+dirPath);@@ -175,7 +175,9 @@ Still Missing:var lastDateModified = 0;if(!isDir) {fileSize = nativeIO.getFileSize(path);- //lastDateModified = new Date(nativeIO.lastDateModified(path)*1000);+ if(isWin) {+ lastDateModified = new Date(nativeIO.getFileLastDateModified(path)*1000);+ }}anotatedDirList.push({"name": dirList[i],@@ -192,7 +194,7 @@ Still Missing:} else {console.error("Directory does not exists.");}- }+ };exports.getSubdirs = function(dirPath) {console.log("Getting subdirs: "+dirPath);@@ -218,7 +220,7 @@ Still Missing:} else {console.error("Directory does not exists.");}- }+ };exports.deleteElement = function(path) {console.log("Deleting: "+path);@@ -228,7 +230,7 @@ Still Missing:} catch(ex) {console.error("Deleting file failed "+ex);}- }+ };exports.createDirectoryIndex = function(dirPath) {console.log("Creating index for directory: "+dirPath);@@ -236,14 +238,14 @@ Still Missing:directoryIndex = scanDirectory(dirPath, directoryIndex);//console.log(JSON.stringify(directoryIndex));TSPOSTIO.createDirectoryIndex(directoryIndex);- }+ };exports.createDirectoryTree = function(dirPath) {console.log("Creating directory index for: "+dirPath);var directoyTree = generateDirectoryTree(dirPath);//console.log(JSON.stringify(directoyTree));TSPOSTIO.createDirectoryTree(directoyTree);- }+ };exports.saveTextFile = function(filePath,content) {console.log("Saving file: "+filePath);@@ -259,9 +261,9 @@ Still Missing:var data = Array.prototype.slice.call(new Uint8Array(reader.result), 0);nativeIO.saveBlobToFile(filePath, data);TSPOSTIO.saveTextFile(filePath);- }+ };reader.readAsArrayBuffer(blob);- }+ };exports.createDirectory = function(dirPath) {console.log("Creating directory: "+dirPath);@@ -271,55 +273,52 @@ Still Missing:} catch(ex) {console.error("Deleting file failed "+ex);}- }+ };exports.renameFile = function(filePath, newFilePath) {- // TODO use a more efficient rename functionality- // currently the file is copied to the new location and than- // deleted from the old location- /*- if(nativeIO.renameFile(filePath, newFilePath)) {- TSPOSTIO.renameFile(filePath, newFilePath);- } else {- console.error("File renaming moving failed!");- } */-console.log("Renaming file: "+filePath+" to "+newFilePath);if(filePath.toLowerCase() == newFilePath.toLowerCase()) {console.error("Initial and target filenames are the same...");return;}- if(nativeIO.fileExists(filePath)) {- var blob;- var size = nativeIO.getFileSize(filePath);- // TODO remove the 5MB restriction- if(size > 5*1024*1024) {- TSCORE.showAlertDialog("Currently TagSpaces does not support renaming/tagging of files bigger than 5MB!");- return;- }- if (size){- var byteArray = nativeIO.contentsAtPath(filePath);- blob = new Int8Array(byteArray);- } else {- blob = new Int8Array(0);- }- var b = new Blob([blob]);- b.size = size;- var reader = new FileReader();- reader.onloadend = function(e){- var data = Array.prototype.slice.call(new Uint8Array(reader.result), 0);- nativeIO.saveBlobToFile(newFilePath, data);- if(nativeIO.fileExists(newFilePath)) {- nativeIO.removeRecursively(filePath);- }- TSPOSTIO.renameFile(filePath,newFilePath);- }- reader.readAsArrayBuffer(b);+ if(isWin) {+ if(nativeIO.renameFile(filePath, newFilePath)) {+ TSPOSTIO.renameFile(filePath, newFilePath);+ } else {+ console.error("File renaming moving failed!");+ }} else {- console.error("File does not exists...");- }-- }+ if(nativeIO.fileExists(filePath)) {+ var blob;+ var size = nativeIO.getFileSize(filePath);+ // TODO remove the 5MB restriction+ if(size > 5*1024*1024) {+ TSCORE.showAlertDialog("In Chrome, TagSpaces does not support renaming/tagging of files bigger than 5MB!");+ return;+ }+ if (size){+ var byteArray = nativeIO.contentsAtPath(filePath);+ blob = new Int8Array(byteArray);+ } else {+ blob = new Int8Array(0);+ }+ var b = new Blob([blob]);+ b.size = size;+ var reader = new FileReader();+ reader.onloadend = function(e){+ var data = Array.prototype.slice.call(new Uint8Array(reader.result), 0);+ nativeIO.saveBlobToFile(newFilePath, data);+ if(nativeIO.fileExists(newFilePath)) {+ nativeIO.removeRecursively(filePath);+ }+ TSPOSTIO.renameFile(filePath,newFilePath);+ };+ reader.readAsArrayBuffer(b);+ } else {+ console.error("File does not exists...");+ }+ }+ };exports.selectDirectory = function() {console.log("Select directory!");@@ -328,7 +327,7 @@ Still Missing:TSPOSTIO.selectDirectory(dirPath);}});- }+ };exports.selectFile = function() {console.log("Select file!");@@ -337,13 +336,13 @@ Still Missing://$("#folderLocation").val(dirPath);}});- }+ };exports.checkAccessFileURLAllowed = function() {chrome.extension.isAllowedFileSchemeAccess(function(isAllowedAccess) {if(!isAllowedAccess) {TSCORE.showAlertDialog(- "Please make shure that you select the 'Allow access to file URLs'"++ "Please make sure that you check the 'Allow access to file URLs'"+" checkbox as shown in the following screenshot "+" from the extension ('chrome://extensions/') settings of chrome/chromium"+"<img src='chrome/ChromeAllowAccessFileURLs.png' />",@@ -351,17 +350,17 @@ Still Missing:);}});- }+ };exports.openDirectory = function(dirPath) {// TODO implement openDirectory- console.log("Open directory functionality not implemented on chrome yet!");+ console.log("Open directory functionality not implemented in chrome yet!");TSCORE.showAlertDialog("Select file functionality not implemented on chrome yet!");- }+ };exports.openExtensionsDirectory = function() {// TODO implement openExtensionsDirectory- console.log("Open extensions directory functionality not implemented on chrome yet!");+ console.log("Open extensions directory functionality not implemented in chrome yet!");TSCORE.showAlertDialog("Open extensions directory functionality not implemented on chrome yet!");- }+ };});