diff options
| author | Gubolin <gubolin@fantasymail.de> | 2015-01-03 11:23:07 +0100 |
|---|---|---|
| committer | Gubolin <gubolin@fantasymail.de> | 2015-01-03 11:23:07 +0100 |
| commit | 618e034eb86b3ad7e7f4955b900862a27a0ce44c (patch) | |
| tree | 8131b44a2e98a13040976150820fd938a24f008b /threads.js | |
| parent | 45033e2101a5d5d0929dd28205f3177059ad865d (diff) | |
| download | snap-618e034eb86b3ad7e7f4955b900862a27a0ce44c.tar.gz snap-618e034eb86b3ad7e7f4955b900862a27a0ce44c.zip | |
remove file blocks
Diffstat (limited to 'threads.js')
| -rw-r--r-- | threads.js | 215 |
1 files changed, 0 insertions, 215 deletions
@@ -2716,221 +2716,6 @@ Process.prototype.reportDate = function (datefn) { return result; }; -// Process File access -// http://www.html5rocks.com/en/tutorials/file/filesystem/ -Process.prototype.fileErrorHandler = function (e) { - var msg = ''; - - switch (e.code) { - case FileError.QUOTA_EXCEEDED_ERR: - msg = localize('no space left'); - break; - case FileError.NOT_FOUND_ERR: - msg = localize('not found'); - break; - case FileError.SECURITY_ERR: - msg = localize('access denied'); - break; - case FileError.INVALID_MODIFICATION_ERR: - msg = 'INVALID_MODIFICATION_ERR'; - break; - case FileError.INVALID_STATE_ERR: - msg = 'INVALID_STATE_ERR'; - break; - default: - msg = localize('unknown error'); - break; - } - - this.handleError(msg); -}; - -Process.prototype.reportFileOrDirectoryContent = function (typeInput, filepath) { - var myself = this; - var type = myself.inputOption(typeInput); - - if (myself.context.result === null) { - myself.context.result = false; - - if (window.resolveLocalFileSystemURL) { - window.resolveLocalFileSystemURL(filepath, - function (entry) { - if (type === 'file') { - entry.file( - function (file) { - var reader = new FileReader(); - - reader.onloadend = function (e) { - myself.context.result = this.result; - }; - - reader.readAsText(file); - }, - myself.fileErrorHandler - ); - } else { - var dirReader = entry.createReader(); - dirReader.readEntries( - function (results) { - var items = []; - results.forEach( - function (item) { - items.push(item.name); - } - ); - myself.context.result = new List(items); - }, - myself.fileErrorHandler - ); - } - }, - myself.fileErrorHandler - ); - } - } else { - if (myself.context.result !== false) { - return myself.context.result; - } - } - - this.pushContext('doYield'); - this.pushContext(); -}; - -Process.prototype.doSetFileContent = function (content, filepath) { - var dirpath = filepath.substring(0, - filepath.lastIndexOf('/')); - var filename = filepath.substring( - filepath.lastIndexOf('/') + 1); - - if (window.resolveLocalFileSystemURL) { - window.resolveLocalFileSystemURL(dirpath, - function (dirEntry) { - dirEntry.getFile(filename, - {create: true, exclusive: false}, - function (fileEntry) { - fileEntry.createWriter( - function (fileWriter) { - var blob; - - try { - blob = new Blob([content], - {type: 'text/plain'}); - // No `new Blob` for Android - } catch (e) { - window.BlobBuilder = - window.BlobBuilder || - window.WebKitBlobBuilder || - window.MozBlobBuilder || - window.MSBlobBuilder; - - if (e.name == 'TypeError' - && window.BlobBuilder) { - var bb = new BlobBuilder(); - bb.append(content); - blob = bb.getBlob('text/plain'); - } - } - - fileWriter.write(blob); - }, - myself.fileErrorHandler - ); - }, - myself.fileErrorHandler - ); - }, - myself.fileErrorHandler - ); - } -}; - -Process.prototype.createFileOrDirectory = function (typeInput, filepath) { - var myself = this; - var type = myself.inputOption(typeInput); - - function createDir(rootDirEntry, folders) { - rootDirEntry.getDirectory(folders[0], {create: true}, - function (dirEntry) { - if (folders.length === 1) { - if (type === 'file') { - dirEntry.getFile(folders.slice(1), - {create: true, exclusive: false}, - function (fileEntry) { - return; - }, - myself.fileErrorHandler - ); - - return; - } - } - - if (folders.length) { - createDir(dirEntry, folders.slice(1)); - } - }, - myself.fileErrorHandler - ); - } - - window.requestFileSystem(window.PERSISTENT, 0, - function (fileSystem) { - createDir(fileSystem.root, path.split('/')); - }, - myself.fileErrorHandler - ); -}; - -Process.prototype.reportFileOrDirectoryExists = function (typeInput, filepath) { - var myself = this; - var type = myself.inputOption(typeInput); - - if (myself.context.result === null) { - myself.context.result = 'wait'; - - if (window.resolveLocalFileSystemURL) { - window.resolveLocalFileSystemURL(filepath, - function (entry) { - if (type === 'file') { - myself.context.result = !entry.isDirectory; - } else { - myself.context.result = entry.isDirectory; - } - }, - myself.fileErrorHandler - ); - } - } else { - if (myself.context.result !== 'wait') { - return myself.context.result; - } - } - - this.pushContext('doYield'); - this.pushContext(); -}; - -Process.prototype.doDeleteFileOrDirectory = function (typeInput, filepath) { - if (window.resolveLocalFileSystemURL) { - window.resolveLocalFileSystemURL(filepath, - function (entry) { - entry.remove(); - }, - myself.fileErrorHandler - ); - } -}; - -Process.prototype.reportHomeDirectory = function () { - if (cordova) { - if (cordova.file) { - return cordova.file.dataDirectory; - } - } - return ''; -}; - Process.prototype.getCompassHeading = function () { var stage = this.homeContext.receiver.parentThatIsA(StageMorph); |
