From 319d4cb6670729708c19ad50b0146d1bcb7b4719 Mon Sep 17 00:00:00 2001 From: PliablePixels Date: Sat, 27 Jun 2015 09:52:06 -0400 Subject: Added ability to log key events to file and email (useful for release debugging) --- plugins/cordova-plugin-file/www/DirectoryEntry.js | 117 +++++++ plugins/cordova-plugin-file/www/DirectoryReader.js | 73 ++++ plugins/cordova-plugin-file/www/Entry.js | 260 ++++++++++++++ plugins/cordova-plugin-file/www/File.js | 79 +++++ plugins/cordova-plugin-file/www/FileEntry.js | 81 +++++ plugins/cordova-plugin-file/www/FileError.js | 46 +++ plugins/cordova-plugin-file/www/FileReader.js | 390 +++++++++++++++++++++ plugins/cordova-plugin-file/www/FileSystem.js | 48 +++ .../cordova-plugin-file/www/FileUploadOptions.js | 41 +++ .../cordova-plugin-file/www/FileUploadResult.js | 30 ++ plugins/cordova-plugin-file/www/FileWriter.js | 302 ++++++++++++++++ plugins/cordova-plugin-file/www/Flags.js | 36 ++ plugins/cordova-plugin-file/www/LocalFileSystem.js | 23 ++ plugins/cordova-plugin-file/www/Metadata.js | 40 +++ plugins/cordova-plugin-file/www/ProgressEvent.js | 67 ++++ .../cordova-plugin-file/www/android/FileSystem.js | 36 ++ .../www/blackberry10/FileProxy.js | 51 +++ .../www/blackberry10/FileSystem.js | 46 +++ .../cordova-plugin-file/www/blackberry10/copyTo.js | 141 ++++++++ .../www/blackberry10/createEntryFromNative.js | 77 ++++ .../www/blackberry10/getDirectory.js | 72 ++++ .../www/blackberry10/getFile.js | 57 +++ .../www/blackberry10/getFileMetadata.js | 65 ++++ .../www/blackberry10/getMetadata.js | 54 +++ .../www/blackberry10/getParent.js | 57 +++ .../cordova-plugin-file/www/blackberry10/info.js | 52 +++ .../cordova-plugin-file/www/blackberry10/moveTo.js | 39 +++ .../www/blackberry10/readAsArrayBuffer.js | 68 ++++ .../www/blackberry10/readAsBinaryString.js | 68 ++++ .../www/blackberry10/readAsDataURL.js | 65 ++++ .../www/blackberry10/readAsText.js | 77 ++++ .../www/blackberry10/readEntries.js | 71 ++++ .../cordova-plugin-file/www/blackberry10/remove.js | 61 ++++ .../www/blackberry10/removeRecursively.js | 62 ++++ .../www/blackberry10/requestAllFileSystems.js | 42 +++ .../www/blackberry10/requestAnimationFrame.js | 38 ++ .../www/blackberry10/requestFileSystem.js | 53 +++ .../www/blackberry10/resolveLocalFileSystemURI.js | 172 +++++++++ .../www/blackberry10/setMetadata.js | 33 ++ .../www/blackberry10/truncate.js | 74 ++++ .../cordova-plugin-file/www/blackberry10/write.js | 73 ++++ .../cordova-plugin-file/www/browser/FileSystem.js | 31 ++ .../cordova-plugin-file/www/browser/Preparing.js | 187 ++++++++++ plugins/cordova-plugin-file/www/fileSystemPaths.js | 63 ++++ .../cordova-plugin-file/www/fileSystems-roots.js | 44 +++ plugins/cordova-plugin-file/www/fileSystems.js | 25 ++ .../www/firefoxos/FileSystem.js | 29 ++ plugins/cordova-plugin-file/www/ios/FileSystem.js | 30 ++ .../cordova-plugin-file/www/requestFileSystem.js | 76 ++++ .../www/resolveLocalFileSystemURI.js | 87 +++++ .../cordova-plugin-file/www/ubuntu/FileSystem.js | 34 ++ .../cordova-plugin-file/www/ubuntu/FileWriter.js | 135 +++++++ .../www/ubuntu/fileSystems-roots.js | 53 +++ .../www/wp/FileUploadOptions.js | 49 +++ 54 files changed, 4180 insertions(+) create mode 100644 plugins/cordova-plugin-file/www/DirectoryEntry.js create mode 100644 plugins/cordova-plugin-file/www/DirectoryReader.js create mode 100644 plugins/cordova-plugin-file/www/Entry.js create mode 100644 plugins/cordova-plugin-file/www/File.js create mode 100644 plugins/cordova-plugin-file/www/FileEntry.js create mode 100644 plugins/cordova-plugin-file/www/FileError.js create mode 100644 plugins/cordova-plugin-file/www/FileReader.js create mode 100644 plugins/cordova-plugin-file/www/FileSystem.js create mode 100644 plugins/cordova-plugin-file/www/FileUploadOptions.js create mode 100644 plugins/cordova-plugin-file/www/FileUploadResult.js create mode 100644 plugins/cordova-plugin-file/www/FileWriter.js create mode 100644 plugins/cordova-plugin-file/www/Flags.js create mode 100644 plugins/cordova-plugin-file/www/LocalFileSystem.js create mode 100644 plugins/cordova-plugin-file/www/Metadata.js create mode 100644 plugins/cordova-plugin-file/www/ProgressEvent.js create mode 100644 plugins/cordova-plugin-file/www/android/FileSystem.js create mode 100644 plugins/cordova-plugin-file/www/blackberry10/FileProxy.js create mode 100644 plugins/cordova-plugin-file/www/blackberry10/FileSystem.js create mode 100644 plugins/cordova-plugin-file/www/blackberry10/copyTo.js create mode 100644 plugins/cordova-plugin-file/www/blackberry10/createEntryFromNative.js create mode 100644 plugins/cordova-plugin-file/www/blackberry10/getDirectory.js create mode 100644 plugins/cordova-plugin-file/www/blackberry10/getFile.js create mode 100644 plugins/cordova-plugin-file/www/blackberry10/getFileMetadata.js create mode 100644 plugins/cordova-plugin-file/www/blackberry10/getMetadata.js create mode 100644 plugins/cordova-plugin-file/www/blackberry10/getParent.js create mode 100644 plugins/cordova-plugin-file/www/blackberry10/info.js create mode 100644 plugins/cordova-plugin-file/www/blackberry10/moveTo.js create mode 100644 plugins/cordova-plugin-file/www/blackberry10/readAsArrayBuffer.js create mode 100644 plugins/cordova-plugin-file/www/blackberry10/readAsBinaryString.js create mode 100644 plugins/cordova-plugin-file/www/blackberry10/readAsDataURL.js create mode 100644 plugins/cordova-plugin-file/www/blackberry10/readAsText.js create mode 100644 plugins/cordova-plugin-file/www/blackberry10/readEntries.js create mode 100644 plugins/cordova-plugin-file/www/blackberry10/remove.js create mode 100644 plugins/cordova-plugin-file/www/blackberry10/removeRecursively.js create mode 100644 plugins/cordova-plugin-file/www/blackberry10/requestAllFileSystems.js create mode 100644 plugins/cordova-plugin-file/www/blackberry10/requestAnimationFrame.js create mode 100644 plugins/cordova-plugin-file/www/blackberry10/requestFileSystem.js create mode 100644 plugins/cordova-plugin-file/www/blackberry10/resolveLocalFileSystemURI.js create mode 100644 plugins/cordova-plugin-file/www/blackberry10/setMetadata.js create mode 100644 plugins/cordova-plugin-file/www/blackberry10/truncate.js create mode 100644 plugins/cordova-plugin-file/www/blackberry10/write.js create mode 100644 plugins/cordova-plugin-file/www/browser/FileSystem.js create mode 100644 plugins/cordova-plugin-file/www/browser/Preparing.js create mode 100644 plugins/cordova-plugin-file/www/fileSystemPaths.js create mode 100644 plugins/cordova-plugin-file/www/fileSystems-roots.js create mode 100644 plugins/cordova-plugin-file/www/fileSystems.js create mode 100644 plugins/cordova-plugin-file/www/firefoxos/FileSystem.js create mode 100644 plugins/cordova-plugin-file/www/ios/FileSystem.js create mode 100644 plugins/cordova-plugin-file/www/requestFileSystem.js create mode 100644 plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.js create mode 100644 plugins/cordova-plugin-file/www/ubuntu/FileSystem.js create mode 100644 plugins/cordova-plugin-file/www/ubuntu/FileWriter.js create mode 100644 plugins/cordova-plugin-file/www/ubuntu/fileSystems-roots.js create mode 100644 plugins/cordova-plugin-file/www/wp/FileUploadOptions.js (limited to 'plugins/cordova-plugin-file/www') diff --git a/plugins/cordova-plugin-file/www/DirectoryEntry.js b/plugins/cordova-plugin-file/www/DirectoryEntry.js new file mode 100644 index 00000000..62f468ab --- /dev/null +++ b/plugins/cordova-plugin-file/www/DirectoryEntry.js @@ -0,0 +1,117 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ + +var argscheck = require('cordova/argscheck'), + utils = require('cordova/utils'), + exec = require('cordova/exec'), + Entry = require('./Entry'), + FileError = require('./FileError'), + DirectoryReader = require('./DirectoryReader'); + +/** + * An interface representing a directory on the file system. + * + * {boolean} isFile always false (readonly) + * {boolean} isDirectory always true (readonly) + * {DOMString} name of the directory, excluding the path leading to it (readonly) + * {DOMString} fullPath the absolute full path to the directory (readonly) + * {FileSystem} filesystem on which the directory resides (readonly) + */ +var DirectoryEntry = function(name, fullPath, fileSystem, nativeURL) { + + // add trailing slash if it is missing + if ((fullPath) && !/\/$/.test(fullPath)) { + fullPath += "/"; + } + // add trailing slash if it is missing + if (nativeURL && !/\/$/.test(nativeURL)) { + nativeURL += "/"; + } + DirectoryEntry.__super__.constructor.call(this, false, true, name, fullPath, fileSystem, nativeURL); +}; + +utils.extend(DirectoryEntry, Entry); + +/** + * Creates a new DirectoryReader to read entries from this directory + */ +DirectoryEntry.prototype.createReader = function() { + return new DirectoryReader(this.toInternalURL()); +}; + +/** + * Creates or looks up a directory + * + * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a directory + * @param {Flags} options to create or exclusively create the directory + * @param {Function} successCallback is called with the new entry + * @param {Function} errorCallback is called with a FileError + */ +DirectoryEntry.prototype.getDirectory = function(path, options, successCallback, errorCallback) { + argscheck.checkArgs('sOFF', 'DirectoryEntry.getDirectory', arguments); + var fs = this.filesystem; + var win = successCallback && function(result) { + var entry = new DirectoryEntry(result.name, result.fullPath, fs, result.nativeURL); + successCallback(entry); + }; + var fail = errorCallback && function(code) { + errorCallback(new FileError(code)); + }; + exec(win, fail, "File", "getDirectory", [this.toInternalURL(), path, options]); +}; + +/** + * Deletes a directory and all of it's contents + * + * @param {Function} successCallback is called with no parameters + * @param {Function} errorCallback is called with a FileError + */ +DirectoryEntry.prototype.removeRecursively = function(successCallback, errorCallback) { + argscheck.checkArgs('FF', 'DirectoryEntry.removeRecursively', arguments); + var fail = errorCallback && function(code) { + errorCallback(new FileError(code)); + }; + exec(successCallback, fail, "File", "removeRecursively", [this.toInternalURL()]); +}; + +/** + * Creates or looks up a file + * + * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a file + * @param {Flags} options to create or exclusively create the file + * @param {Function} successCallback is called with the new entry + * @param {Function} errorCallback is called with a FileError + */ +DirectoryEntry.prototype.getFile = function(path, options, successCallback, errorCallback) { + argscheck.checkArgs('sOFF', 'DirectoryEntry.getFile', arguments); + var fs = this.filesystem; + var win = successCallback && function(result) { + var FileEntry = require('./FileEntry'); + var entry = new FileEntry(result.name, result.fullPath, fs, result.nativeURL); + successCallback(entry); + }; + var fail = errorCallback && function(code) { + errorCallback(new FileError(code)); + }; + exec(win, fail, "File", "getFile", [this.toInternalURL(), path, options]); +}; + +module.exports = DirectoryEntry; diff --git a/plugins/cordova-plugin-file/www/DirectoryReader.js b/plugins/cordova-plugin-file/www/DirectoryReader.js new file mode 100644 index 00000000..2894c9a3 --- /dev/null +++ b/plugins/cordova-plugin-file/www/DirectoryReader.js @@ -0,0 +1,73 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ + +var exec = require('cordova/exec'), + FileError = require('./FileError') ; + +/** + * An interface that lists the files and directories in a directory. + */ +function DirectoryReader(localURL) { + this.localURL = localURL || null; + this.hasReadEntries = false; +} + +/** + * Returns a list of entries from a directory. + * + * @param {Function} successCallback is called with a list of entries + * @param {Function} errorCallback is called with a FileError + */ +DirectoryReader.prototype.readEntries = function(successCallback, errorCallback) { + // If we've already read and passed on this directory's entries, return an empty list. + if (this.hasReadEntries) { + successCallback([]); + return; + } + var reader = this; + var win = typeof successCallback !== 'function' ? null : function(result) { + var retVal = []; + for (var i=0; i or + *