Updated Branches: refs/heads/master 0e89b601a -> 08a2641cf
[CB-3720] [BlackBerry10] Remove File overrides (moving to plugin) Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/5409661d Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/5409661d Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/5409661d Branch: refs/heads/master Commit: 5409661db6ff9691b9e7a7c6d47b51e5b07cf828 Parents: 0e89b60 Author: Bryan Higgins <[email protected]> Authored: Fri Jun 28 14:37:45 2013 -0400 Committer: Bryan Higgins <[email protected]> Committed: Thu Jul 4 10:26:39 2013 -0400 ---------------------------------------------------------------------- lib/blackberry10/plugin/DirectoryEntry.js | 57 --------- lib/blackberry10/plugin/DirectoryReader.js | 47 -------- lib/blackberry10/plugin/Entry.js | 112 ----------------- lib/blackberry10/plugin/FileEntry.js | 47 -------- lib/blackberry10/plugin/FileReader.js | 90 -------------- lib/blackberry10/plugin/FileSystem.js | 27 ----- lib/blackberry10/plugin/FileWriter.js | 120 ------------------- lib/blackberry10/plugin/requestFileSystem.js | 38 ------ .../plugin/resolveLocalFileSystemURI.js | 55 --------- 9 files changed, 593 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-js/blob/5409661d/lib/blackberry10/plugin/DirectoryEntry.js ---------------------------------------------------------------------- diff --git a/lib/blackberry10/plugin/DirectoryEntry.js b/lib/blackberry10/plugin/DirectoryEntry.js deleted file mode 100644 index 259a79e..0000000 --- a/lib/blackberry10/plugin/DirectoryEntry.js +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * 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'), - Entry = require('cordova/plugin/Entry'), - FileError = require('cordova/plugin/FileError'), - DirectoryReader = require('cordova/plugin/DirectoryReader'), - fileUtils = require('cordova/plugin/blackberry10/fileUtils'), - DirectoryEntry = function (name, fullPath) { - DirectoryEntry.__super__.constructor.call(this, false, true, name, fullPath); - }; - -utils.extend(DirectoryEntry, Entry); - -DirectoryEntry.prototype.createReader = function () { - return new DirectoryReader(this.fullPath); -}; - -DirectoryEntry.prototype.getDirectory = function (path, options, successCallback, errorCallback) { - argscheck.checkArgs('sOFF', 'DirectoryEntry.getDirectory', arguments); - this.nativeEntry.getDirectory(path, options, function (entry) { - successCallback(fileUtils.createEntry(entry)); - }, errorCallback); -}; - -DirectoryEntry.prototype.removeRecursively = function (successCallback, errorCallback) { - argscheck.checkArgs('FF', 'DirectoryEntry.removeRecursively', arguments); - this.nativeEntry.removeRecursively(successCallback, errorCallback); -}; - -DirectoryEntry.prototype.getFile = function (path, options, successCallback, errorCallback) { - argscheck.checkArgs('sOFF', 'DirectoryEntry.getFile', arguments); - this.nativeEntry.getFile(path, options, function (entry) { - successCallback(fileUtils.createEntry(entry)); - }, errorCallback); -}; - -module.exports = DirectoryEntry; http://git-wip-us.apache.org/repos/asf/cordova-js/blob/5409661d/lib/blackberry10/plugin/DirectoryReader.js ---------------------------------------------------------------------- diff --git a/lib/blackberry10/plugin/DirectoryReader.js b/lib/blackberry10/plugin/DirectoryReader.js deleted file mode 100644 index 8bb9968..0000000 --- a/lib/blackberry10/plugin/DirectoryReader.js +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * 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 FileError = require('cordova/plugin/FileError'), - fileUtils = require('cordova/plugin/blackberry10/fileUtils'); - -function DirectoryReader(path) { - this.path = path; -} - -DirectoryReader.prototype.readEntries = function(successCallback, errorCallback) { - var win = typeof successCallback !== 'function' ? null : function(result) { - var retVal = []; - for (var i=0; i<result.length; i++) { - retVal.push(fileUtils.createEntry(result[i])); - } - successCallback(retVal); - }, - fail = typeof errorCallback !== 'function' ? null : function(code) { - errorCallback(new FileError(code)); - }; - fileUtils.getEntryForURI(this.path, function (entry) { - entry.nativeEntry.createReader().readEntries(win, fail); - }, function () { - fail(FileError.NOT_FOUND_ERR); - }); -}; - -module.exports = DirectoryReader; http://git-wip-us.apache.org/repos/asf/cordova-js/blob/5409661d/lib/blackberry10/plugin/Entry.js ---------------------------------------------------------------------- diff --git a/lib/blackberry10/plugin/Entry.js b/lib/blackberry10/plugin/Entry.js deleted file mode 100644 index cf971fe..0000000 --- a/lib/blackberry10/plugin/Entry.js +++ /dev/null @@ -1,112 +0,0 @@ -/* - * - * 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'), - FileError = require('cordova/plugin/FileError'), - Metadata = require('cordova/plugin/Metadata'), - fileUtils = require('cordova/plugin/blackberry10/fileUtils'); - -function Entry(isFile, isDirectory, name, fullPath, fileSystem) { - this.isFile = !!isFile; - this.isDirectory = !!isDirectory; - this.name = name || ''; - this.fullPath = fullPath || ''; - this.filesystem = fileSystem || null; -} - -Entry.prototype.getMetadata = function(successCallback, errorCallback) { - argscheck.checkArgs('FF', 'Entry.getMetadata', arguments); - var success = function(lastModified) { - var metadata = new Metadata(lastModified); - if (typeof successCallback === 'function') { - successCallback(metadata); - } - }; - this.nativeEntry.getMetadata(success, errorCallback); -}; - -Entry.prototype.setMetadata = function(successCallback, errorCallback, metadataObject) { - argscheck.checkArgs('FFO', 'Entry.setMetadata', arguments); - errorCallback("Not supported by platform"); -}; - -Entry.prototype.moveTo = function(parent, newName, successCallback, errorCallback) { - argscheck.checkArgs('oSFF', 'Entry.moveTo', arguments); - var srcPath = this.fullPath, - name = newName || this.name, - success = function(entry) { - if (entry) { - if (typeof successCallback === 'function') { - successCallback(fileUtils.createEntry(entry)); - } - } - else { - if (typeof errorCallback === 'function') { - errorCallback(new FileError(FileError.NOT_FOUND_ERR)); - } - } - }; - this.nativeEntry.moveTo(parent.nativeEntry, newName, success, errorCallback); -}; - - -Entry.prototype.copyTo = function(parent, newName, successCallback, errorCallback) { - argscheck.checkArgs('oSFF', 'Entry.copyTo', arguments); - var srcPath = this.fullPath, - name = newName || this.name, - success = function(entry) { - if (entry) { - if (typeof successCallback === 'function') { - successCallback(fileUtils.createEntry(entry)); - } - } - else { - if (typeof errorCallback === 'function') { - errorCallback(new FileError(FileError.NOT_FOUND_ERR)); - } - } - }; - this.nativeEntry.copyTo(parent.nativeEntry, newName, success, errorCallback); -}; - -Entry.prototype.toURL = function() { - return this.fullPath; -}; - -Entry.prototype.toURI = function(mimeType) { - console.log("DEPRECATED: Update your code to use 'toURL'"); - return this.toURL(); -}; - -Entry.prototype.remove = function(successCallback, errorCallback) { - argscheck.checkArgs('FF', 'Entry.remove', arguments); - this.nativeEntry.remove(successCallback, errorCallback); -}; - -Entry.prototype.getParent = function(successCallback, errorCallback) { - argscheck.checkArgs('FF', 'Entry.getParent', arguments); - var win = successCallback && function(result) { - successCallback(fileUtils.createEntry(result)); - }; - this.nativeEntry.getParent(win, errorCallback); -}; - -module.exports = Entry; http://git-wip-us.apache.org/repos/asf/cordova-js/blob/5409661d/lib/blackberry10/plugin/FileEntry.js ---------------------------------------------------------------------- diff --git a/lib/blackberry10/plugin/FileEntry.js b/lib/blackberry10/plugin/FileEntry.js deleted file mode 100644 index 17f9393..0000000 --- a/lib/blackberry10/plugin/FileEntry.js +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * 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 utils = require('cordova/utils'), - Entry = require('cordova/plugin/Entry'), - FileWriter = require('cordova/plugin/FileWriter'), - File = require('cordova/plugin/File'), - FileError = require('cordova/plugin/FileError'), - FileEntry = function (name, fullPath) { - FileEntry.__super__.constructor.apply(this, [true, false, name, fullPath]); - }; - -utils.extend(FileEntry, Entry); - -FileEntry.prototype.createWriter = function(successCallback, errorCallback) { - this.file(function (file) { - successCallback(new FileWriter(file)); - }, errorCallback); -}; - -FileEntry.prototype.file = function(successCallback, errorCallback) { - var fullPath = this.fullPath, - success = function (file) { - successCallback(new File(file.name, fullPath, file.type, file.lastModifiedDate, file.size)); - }; - this.nativeEntry.file(success, errorCallback); -}; - -module.exports = FileEntry; http://git-wip-us.apache.org/repos/asf/cordova-js/blob/5409661d/lib/blackberry10/plugin/FileReader.js ---------------------------------------------------------------------- diff --git a/lib/blackberry10/plugin/FileReader.js b/lib/blackberry10/plugin/FileReader.js deleted file mode 100644 index 17214ef..0000000 --- a/lib/blackberry10/plugin/FileReader.js +++ /dev/null @@ -1,90 +0,0 @@ -/* - * - * 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 origFileReader = window.FileReader, - fileUtils = require('cordova/plugin/blackberry10/fileUtils'), - utils = require('cordova/utils'); - -var FileReader = function() { - this.nativeReader = new origFileReader(); -}; - -utils.defineGetter(FileReader.prototype, 'readyState', function() { - return this.nativeReader.readyState; -}); - -utils.defineGetter(FileReader.prototype, 'error', function() { - return this.nativeReader.error; -}); - -utils.defineGetter(FileReader.prototype, 'result', function() { - return this.nativeReader.result; -}); - -function defineEvent(eventName) { - utils.defineGetterSetter(FileReader.prototype, eventName, function() { - return this.nativeReader[eventName] || null; - }, function(value) { - this.nativeReader[eventName] = value; - }); -} - -defineEvent('onabort'); -defineEvent('onerror'); -defineEvent('onload'); -defineEvent('onloadend'); -defineEvent('onloadstart'); -defineEvent('onprogress'); - -FileReader.prototype.abort = function() { - return this.nativeReader.abort(); -}; - -function read(method, context, file, encoding) { - if (file.fullPath) { - fileUtils.getEntryForURI(file.fullPath, function (entry) { - entry.nativeEntry.file(function (nativeFile) { - context.nativeReader[method].call(context.nativeReader, nativeFile, encoding); - }, context.onerror); - }, context.onerror); - } else { - context.nativeReader[method](file, encoding); - } -} - -FileReader.prototype.readAsText = function(file, encoding) { - read("readAsText", this, file, encoding); -}; - -FileReader.prototype.readAsDataURL = function(file) { - read("readAsDataURL", this, file); -}; - -FileReader.prototype.readAsBinaryString = function(file) { - read("readAsBinaryString", this, file); -}; - -FileReader.prototype.readAsArrayBuffer = function(file) { - read("readAsArrayBuffer", this, file); -}; - -window.FileReader = FileReader; -module.exports = FileReader; http://git-wip-us.apache.org/repos/asf/cordova-js/blob/5409661d/lib/blackberry10/plugin/FileSystem.js ---------------------------------------------------------------------- diff --git a/lib/blackberry10/plugin/FileSystem.js b/lib/blackberry10/plugin/FileSystem.js deleted file mode 100644 index d1432d6..0000000 --- a/lib/blackberry10/plugin/FileSystem.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - * - * 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. - * -*/ - -module.exports = function(name, root) { - this.name = name || null; - if (root) { - this.root = root; - } -}; http://git-wip-us.apache.org/repos/asf/cordova-js/blob/5409661d/lib/blackberry10/plugin/FileWriter.js ---------------------------------------------------------------------- diff --git a/lib/blackberry10/plugin/FileWriter.js b/lib/blackberry10/plugin/FileWriter.js deleted file mode 100644 index 0f71d6a..0000000 --- a/lib/blackberry10/plugin/FileWriter.js +++ /dev/null @@ -1,120 +0,0 @@ -/* - * - * 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 FileError = require('cordova/plugin/FileError'), - ProgressEvent = require('cordova/plugin/ProgressEvent'), - fileUtils = require('cordova/plugin/blackberry10/fileUtils'), - utils = require('cordova/utils'); - -function FileWriter (file) { - var that = this; - this.file = file; - this.events = {}; - this.pending = []; - fileUtils.getEntryForURI(file.fullPath, function (entry) { - entry.nativeEntry.createWriter(function (writer) { - var i, - event; - that.nativeWriter = writer; - for (event in that.events) { - if (that.events.hasOwnProperty(event)) { - that.nativeWriter[event] = that.events[event]; - } - } - for (i = 0; i < that.pending.length; i++) { - that.pending[i](); - } - }); - }); - this.events = {}; - this.pending = []; -} - -utils.defineGetter(FileWriter.prototype, 'error', function() { - return this.nativeWriter ? this.nativeWriter.error : null; -}); - -utils.defineGetter(FileWriter.prototype, 'fileName', function() { - return this.nativeWriter ? this.nativeWriter.fileName : this.file.name; -}); - -utils.defineGetter(FileWriter.prototype, 'length', function() { - return this.nativeWriter ? this.nativeWriter.length : this.file.size; -}); - -utils.defineGetter(FileWriter.prototype, 'position', function() { - return this.nativeWriter ? this.nativeWriter.position : 0; -}); - -utils.defineGetter(FileWriter.prototype, 'readyState', function() { - return this.nativeWriter ? this.nativeWriter.readyState : 0; -}); - -function defineEvent(eventName) { - utils.defineGetterSetter(FileWriter.prototype, eventName, function() { - return this.nativeWriter ? this.nativeWriter[eventName] || null : this.events[eventName] || null; - }, function(value) { - if (this.nativeWriter) { - this.nativeWriter[eventName] = value; - } - else { - this.events[eventName] = value; - } - }); -} - -defineEvent('onabort'); -defineEvent('onerror'); -defineEvent('onprogress'); -defineEvent('onwrite'); -defineEvent('onwriteend'); -defineEvent('onwritestart'); - -FileWriter.prototype.abort = function() { - this.nativeWriter.abort(); -}; - -FileWriter.prototype.write = function(text) { - var that = this, - op = function () { - that.nativeWriter.write(new Blob([text])); - }; - this.nativeWriter ? op() : this.pending.push(op); - -}; - -FileWriter.prototype.seek = function(offset) { - var that = this, - op = function () { - that.nativeWriter.seek(offset); - }; - this.nativeWriter ? op() : this.pending.push(op); -}; - -FileWriter.prototype.truncate = function(size) { - var that = this, - op = function () { - that.nativeWriter.truncate(size); - }; - this.nativeWriter ? op() : this.pending.push(op); -}; - -module.exports = FileWriter; http://git-wip-us.apache.org/repos/asf/cordova-js/blob/5409661d/lib/blackberry10/plugin/requestFileSystem.js ---------------------------------------------------------------------- diff --git a/lib/blackberry10/plugin/requestFileSystem.js b/lib/blackberry10/plugin/requestFileSystem.js deleted file mode 100644 index 62e1753..0000000 --- a/lib/blackberry10/plugin/requestFileSystem.js +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * 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 fileUtils = require('cordova/plugin/blackberry10/fileUtils'), - FileError = require('cordova/plugin/FileError'), - FileSystem = require('cordova/plugin/FileSystem'); - -module.exports = function (type, size, success, fail) { - if (size >= 1000000000000000) { - fail(new FileError(FileError.QUOTA_EXCEEDED_ERR)); - } else if (type !== 1 && type !== 0) { - fail(new FileError(FileError.SYNTAX_ERR)); - } else { - window.webkitRequestFileSystem(type, size, function (fs) { - success((new FileSystem(fileUtils.getFileSystemName(fs), fileUtils.createEntry(fs.root)))); - }, function (error) { - fail(new FileError(error)); - }); - } -}; http://git-wip-us.apache.org/repos/asf/cordova-js/blob/5409661d/lib/blackberry10/plugin/resolveLocalFileSystemURI.js ---------------------------------------------------------------------- diff --git a/lib/blackberry10/plugin/resolveLocalFileSystemURI.js b/lib/blackberry10/plugin/resolveLocalFileSystemURI.js deleted file mode 100644 index d11b0ca..0000000 --- a/lib/blackberry10/plugin/resolveLocalFileSystemURI.js +++ /dev/null @@ -1,55 +0,0 @@ -/* - * - * 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 fileUtils = require('cordova/plugin/blackberry10/fileUtils'), - FileError = require('cordova/plugin/FileError'); - -module.exports = function (uri, success, fail) { - var type, - path, - paramPath; - if (!uri || uri.indexOf("/") === 0) { - fail(new FileError(FileError.ENCODING_ERR)); - } else { - type = uri.indexOf("persistent") === -1 ? 0 : 1; - path = uri.substring(type === 1 ? uri.indexOf("persistent") + 11 : uri.indexOf("temporary") + 10); - if (path.substring(0,1) == "/") { - path = path.substring(1); - } - paramPath = path.indexOf("?"); - if (paramPath > -1) { - path = path.substring(0, paramPath); - } - window.webkitRequestFileSystem(type, 25*1024*1024, function (fs) { - if (path === "") { - success(fileUtils.createEntry(fs.root)); - } else { - fs.root.getDirectory(path, {}, function (entry) { - success(fileUtils.createEntry(entry)); - }, function () { - fs.root.getFile(path, {}, function (entry) { - success(fileUtils.createEntry(entry)); - }, fail); - }); - } - }, fail); - } -};
