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 | |
| parent | 45033e2101a5d5d0929dd28205f3177059ad865d (diff) | |
| download | snap-618e034eb86b3ad7e7f4955b900862a27a0ce44c.tar.gz snap-618e034eb86b3ad7e7f4955b900862a27a0ce44c.zip | |
remove file blocks
| -rw-r--r-- | blocks.js | 12 | ||||
| -rwxr-xr-x | mobile.sh | 1 | ||||
| -rw-r--r-- | objects.js | 44 | ||||
| -rw-r--r-- | threads.js | 215 |
4 files changed, 0 insertions, 272 deletions
@@ -844,18 +844,6 @@ SyntaxElementMorph.prototype.labelPart = function (spec) { ); part.setContents(['date']); break; - case '%fileOrDir': - part = new InputSlotMorph( - null, // text - false, // non-numeric - { - 'file': ['file'], - 'directory': ['directory'] - }, - true // read-only - ); - part.setContents(['file']); - break; case '%locations': part = new InputSlotMorph( null, // text @@ -53,7 +53,6 @@ cordova plugin add org.apache.cordova.device-motion cordova plugin add org.apache.cordova.device-orientation cordova plugin add org.apache.cordova.geolocation cordova plugin add de.appplant.cordova.plugin.local-notification -cordova plugin add org.apache.cordova.file if [[ $1 == "android" ]] then @@ -910,36 +910,6 @@ SpriteMorph.prototype.initBlocks = function () { category: 'sensing', spec: 'current %dates' }, - reportFileOrDirectoryContent: { - type: 'reporter', - category: 'sensing', - spec: 'content of the %fileOrDir %s' - }, - doSetFileContent: { - type: 'command', - category: 'sensing', - spec: 'write %s to the file %s' - }, - doCreateFileOrDirectory: { - type: 'command', - category: 'sensing', - spec: 'create %fileOrDir %s' - }, - reportFileOrDirectoryExists: { - type: 'predicate', - category: 'sensing', - spec: '%fileOrDir %s exists' - }, - doDeleteFileOrDirectory: { - type: 'command', - category: 'sensing', - spec: 'delete the %fileOrDir %s' - }, - reportHomeDirectory: { - type: 'reporter', - category: 'sensing', - spec: 'home directory' - }, doVibrate: { type: 'command', category: 'sensing', @@ -1988,13 +1958,6 @@ SpriteMorph.prototype.blockTemplates = function (category) { blocks.push('-'); blocks.push(block('reportDate')); blocks.push('-'); - blocks.push(block('reportFileOrDirectoryContent')); - blocks.push(block('doSetFileContent')); - blocks.push(block('doCreateFileOrDirectory')); - blocks.push(block('reportFileOrDirectoryExists')); - blocks.push(block('doDeleteFileOrDirectory')); - blocks.push(block('reportHomeDirectory')); - blocks.push('-'); blocks.push(block('reportLanguage')); blocks.push(block('reportLocation')); blocks.push('-'); @@ -5125,13 +5088,6 @@ StageMorph.prototype.blockTemplates = function (category) { blocks.push('-'); blocks.push(block('reportDate')); blocks.push('-'); - blocks.push(block('reportFileOrDirectoryContent')); - blocks.push(block('doSetFileContent')); - blocks.push(block('doCreateFileOrDirectory')); - blocks.push(block('reportFileOrDirectoryExists')); - blocks.push(block('doDeleteFileOrDirectory')); - blocks.push(block('reportHomeDirectory')); - blocks.push('-'); blocks.push(block('reportLanguage')); blocks.push(block('reportLocation')); blocks.push('-'); @@ -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); |
