diff options
| author | PliablePixels <pliablepixels@gmail.com> | 2015-06-25 16:10:07 -0400 |
|---|---|---|
| committer | PliablePixels <pliablepixels@gmail.com> | 2015-06-25 16:10:07 -0400 |
| commit | 65e7255c868bed3bb950e7e36ab786934edc559f (patch) | |
| tree | 085a58a4bc4a55111803dde9ab412dec9e9a8bb1 /plugins/org.apache.cordova.file/www/blackberry10 | |
| parent | 855a0e8ddc273b58066530a1b55a946021dfc56e (diff) | |
https now works with self-signed certificates (needs provisioning though)
Diffstat (limited to 'plugins/org.apache.cordova.file/www/blackberry10')
11 files changed, 0 insertions, 779 deletions
diff --git a/plugins/org.apache.cordova.file/www/blackberry10/DirectoryEntry.js b/plugins/org.apache.cordova.file/www/blackberry10/DirectoryEntry.js deleted file mode 100644 index cb6628d5..00000000 --- a/plugins/org.apache.cordova.file/www/blackberry10/DirectoryEntry.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'), - utils = require('cordova/utils'), - Entry = require('./BB10Entry'), - FileError = require('./FileError'), - DirectoryReader = require('./BB10DirectoryReader'), - fileUtils = require('./BB10Utils'), - DirectoryEntry = function (name, fullPath, fileSystem) { - DirectoryEntry.__super__.constructor.call(this, false, true, name, fullPath, fileSystem); - }; - -utils.extend(DirectoryEntry, Entry); - -function err(sandboxState, errorCallback) { - return function (e) { - cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [sandboxState]); - errorCallback(e); - } -}; - -DirectoryEntry.prototype.createReader = function () { - return new DirectoryReader(this.fullPath); -}; - -DirectoryEntry.prototype.getDirectory = function (path, options, successCallback, errorCallback) { - var sandboxState, - currentPath = this.nativeEntry.fullPath; - - cordova.exec(function (sandboxed) { - sandboxState = sandboxed; - }, function (e) { - console.log("[ERROR]: Could not retrieve sandbox state ", e); - }, "org.apache.cordova.file", "isSandboxed"); - - argscheck.checkArgs('sOFF', 'DirectoryEntry.getDirectory', arguments); - - if (fileUtils.isOutsideSandbox(path)) { - cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [false]); - window.webkitRequestFileSystem(window.PERSISTENT, this.filesystem._size, function (fs) { - cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [sandboxState]); - fs.root.getDirectory(currentPath + '/' + path, options, function (entry) { - successCallback(fileUtils.createEntry(entry)); - }, err(sandboxState, errorCallback)); - }, err(sandboxState, errorCallback)); - } else { - cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [true]); - window.webkitRequestFileSystem(fileUtils.getFileSystemName(this.filesystem) === "persistent" ? window.PERSISTENT : window.TEMPORARY, this.filesystem._size, function (fs) { - cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [sandboxState]); - fs.root.getDirectory(currentPath + '/' + path, options, function (entry) { - successCallback(fileUtils.createEntry(entry)); - }, err(sandboxState, errorCallback)); - }, err(sandboxState, 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) { - var sandboxState, - currentPath = this.nativeEntry.fullPath; - - cordova.exec(function (sandboxed) { - sandboxState = sandboxed; - }, function (e) { - console.log("[ERROR]: Could not retrieve sandbox state ", e); - }, "org.apache.cordova.file", "isSandboxed"); - - argscheck.checkArgs('sOFF', 'DirectoryEntry.getFile', arguments); - - if (fileUtils.isOutsideSandbox(path)) { - cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [false]); - window.webkitRequestFileSystem(window.PERSISTENT, this.filesystem._size, function (fs) { - cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [sandboxState]); - fs.root.getFile(currentPath + '/' + path, options, function (entry) { - successCallback(fileUtils.createEntry(entry)); - }, err(sandboxState, errorCallback)); - }, err(sandboxState, errorCallback)); - } else { - cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [true]); - window.webkitRequestFileSystem(fileUtils.getFileSystemName(this.filesystem) === "persistent" ? window.PERSISTENT: window.TEMPORARY, this.filesystem._size, function (fs) { - cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [sandboxState]); - fs.root.getFile(currentPath + '/' + path, options, function (entry) { - successCallback(fileUtils.createEntry(entry)); - }, err(sandboxState, errorCallback)); - }, err(sandboxState, errorCallback)); - } -}; - -module.exports = DirectoryEntry; diff --git a/plugins/org.apache.cordova.file/www/blackberry10/DirectoryReader.js b/plugins/org.apache.cordova.file/www/blackberry10/DirectoryReader.js deleted file mode 100644 index 6aa3d730..00000000 --- a/plugins/org.apache.cordova.file/www/blackberry10/DirectoryReader.js +++ /dev/null @@ -1,54 +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('./FileError'), - fileUtils = require('./BB10Utils'); - -function DirectoryReader(path) { - this.path = path; - this.nativeReader = null; -} - -DirectoryReader.prototype.readEntries = function(successCallback, errorCallback) { - var self = this, - 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)); - }; - if (this.nativeReader) { - this.nativeReader.readEntries(win, fail); - } else { - resolveLocalFileSystemURI("filesystem:local:///persistent/" + this.path, function (entry) { - self.nativeReader = entry.nativeEntry.createReader() - self.nativeReader.readEntries(win, fail); - }, function () { - fail(FileError.NOT_FOUND_ERR); - }); - } -}; - -module.exports = DirectoryReader; diff --git a/plugins/org.apache.cordova.file/www/blackberry10/Entry.js b/plugins/org.apache.cordova.file/www/blackberry10/Entry.js deleted file mode 100644 index d432bfde..00000000 --- a/plugins/org.apache.cordova.file/www/blackberry10/Entry.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 argscheck = require('cordova/argscheck'), - FileError = require('./FileError'), - Metadata = require('./Metadata'), - fileUtils = require('./BB10Utils'); - -function Entry(isFile, isDirectory, name, fullPath, fileSystem) { - var strippedPath; - if (fullPath && fullPath.charAt(fullPath.length - 1) === '/') { - strippedPath = fullPath.slice(0, -1); - } - this.isFile = !!isFile; - this.isDirectory = !!isDirectory; - this.name = name || ''; - this.fullPath = typeof strippedPath !== "undefined" ? strippedPath : (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() { - var nativeURI = this.nativeEntry.toURL(); - if (nativeURI.charAt(nativeURI.length - 1) === '/') { - return nativeURI.slice(0, -1); - } - return nativeURI; -}; - -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; diff --git a/plugins/org.apache.cordova.file/www/blackberry10/File.js b/plugins/org.apache.cordova.file/www/blackberry10/File.js deleted file mode 100644 index 7ba9734e..00000000 --- a/plugins/org.apache.cordova.file/www/blackberry10/File.js +++ /dev/null @@ -1,56 +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('./BB10Utils'); - -/** - * Constructor. - * name {DOMString} name of the file, without path information - * fullPath {DOMString} the full path of the file, including the name - * type {DOMString} mime type - * lastModifiedDate {Date} last modified date - * size {Number} size of the file in bytes - */ - -var File = function(name, fullPath, type, lastModifiedDate, size){ - this.name = name || ''; - this.fullPath = fullPath || null; - this.type = type || null; - this.lastModifiedDate = lastModifiedDate || null; - this.size = size || 0; - - // These store the absolute start and end for slicing the file. - this.start = 0; - this.end = this.size; -}; - -/** - * Returns a "slice" of the file. - * Slices of slices are supported. - * start {Number} The index at which to start the slice (inclusive). - * end {Number} The index at which to end the slice (exclusive). - */ -File.prototype.slice = function(start, end) { - return fileUtils.createFile(this.nativeFile.slice(start, end)); -}; - - -module.exports = File; diff --git a/plugins/org.apache.cordova.file/www/blackberry10/FileEntry.js b/plugins/org.apache.cordova.file/www/blackberry10/FileEntry.js deleted file mode 100644 index b358d71a..00000000 --- a/plugins/org.apache.cordova.file/www/blackberry10/FileEntry.js +++ /dev/null @@ -1,49 +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('./BB10Entry'), - FileWriter = require('./BB10FileWriter'), - File = require('./BB10File'), - fileUtils = require('./BB10Utils'), - FileError = require('./FileError'), - FileEntry = function (name, fullPath, fileSystem) { - FileEntry.__super__.constructor.apply(this, [true, false, name, fullPath, fileSystem]); - }; - -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) { - file.fullPath = fullPath; - successCallback(fileUtils.createFile(file)); - }; - this.nativeEntry.file(success, errorCallback); -}; - -module.exports = FileEntry; diff --git a/plugins/org.apache.cordova.file/www/blackberry10/FileReader.js b/plugins/org.apache.cordova.file/www/blackberry10/FileReader.js deleted file mode 100644 index 6e3a10c6..00000000 --- a/plugins/org.apache.cordova.file/www/blackberry10/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('./BB10Utils'), - 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) { - resolveLocalFileSystemURI("filesystem:local:///persistent/" + 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; diff --git a/plugins/org.apache.cordova.file/www/blackberry10/FileSystem.js b/plugins/org.apache.cordova.file/www/blackberry10/FileSystem.js deleted file mode 100644 index d1432d6d..00000000 --- a/plugins/org.apache.cordova.file/www/blackberry10/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; - } -}; diff --git a/plugins/org.apache.cordova.file/www/blackberry10/FileWriter.js b/plugins/org.apache.cordova.file/www/blackberry10/FileWriter.js deleted file mode 100644 index 8992943e..00000000 --- a/plugins/org.apache.cordova.file/www/blackberry10/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('./FileError'), - ProgressEvent = require('./ProgressEvent'), - fileUtils = require('./BB10Utils'), - utils = require('cordova/utils'); - -function FileWriter (file) { - var that = this; - this.file = file; - this.events = {}; - this.pending = []; - resolveLocalFileSystemURI("filesystem:local:///persistent/" + 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; diff --git a/plugins/org.apache.cordova.file/www/blackberry10/fileUtils.js b/plugins/org.apache.cordova.file/www/blackberry10/fileUtils.js deleted file mode 100644 index 6f803b73..00000000 --- a/plugins/org.apache.cordova.file/www/blackberry10/fileUtils.js +++ /dev/null @@ -1,52 +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. - * - */ - -function convertPath(url) { - return decodeURI(url).substring(11).replace(/\/$/, ''); -} - -module.exports = { - createEntry: function (entry) { - var cordovaEntry; - if (entry.isFile) { - cordovaEntry = new window.FileEntry(entry.name, entry.fullPath, entry.filesystem); - } else { - cordovaEntry = new window.DirectoryEntry(entry.name, entry.fullPath, entry.filesystem); - } - cordovaEntry.nativeEntry = entry; - return cordovaEntry; - }, - - createFile: function (file) { - var cordovaFile = new File(file.name, file.fullPath, file.type, file.lastModifiedDate, file.size); - cordovaFile.nativeFile = file; - cordovaFile.fullPath = file.name; - return cordovaFile; - }, - - getFileSystemName: function (fs) { - return ((fs.name.indexOf('Persistent') != -1) || (fs.name === "persistent")) ? 'persistent' : 'temporary'; - }, - - isOutsideSandbox: function (path) { - return (path.indexOf("accounts/1000/") === 0 || path.indexOf("/accounts/1000/") === 0); - } -}; diff --git a/plugins/org.apache.cordova.file/www/blackberry10/requestFileSystem.js b/plugins/org.apache.cordova.file/www/blackberry10/requestFileSystem.js deleted file mode 100644 index bd07d089..00000000 --- a/plugins/org.apache.cordova.file/www/blackberry10/requestFileSystem.js +++ /dev/null @@ -1,44 +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('./BB10Utils'), - FileError = require('./FileError'), - FileSystem = require('./BB10FileSystem'); - -module.exports = function (type, size, success, fail) { - var cordovaFs, - cordovaFsRoot; - 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) { - cordovaFsRoot = fileUtils.createEntry(fs.root); - cordovaFs = new FileSystem(fileUtils.getFileSystemName(fs), cordovaFsRoot); - cordovaFsRoot.filesystem = cordovaFs; - cordovaFs._size = size; - success(cordovaFs); - }, function (error) { - fail(new FileError(error)); - }); - } -}; diff --git a/plugins/org.apache.cordova.file/www/blackberry10/resolveLocalFileSystemURI.js b/plugins/org.apache.cordova.file/www/blackberry10/resolveLocalFileSystemURI.js deleted file mode 100644 index 4d5af613..00000000 --- a/plugins/org.apache.cordova.file/www/blackberry10/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('./BB10Utils'), - FileError = require('./FileError'); - -function stripURI(uri) { - var rmFsLocal = uri.substring("filesystem:local:///".length); - return rmFsLocal.substring(rmFsLocal.indexOf('/') + 1); -} - -module.exports = function (uri, success, fail) { - var sandboxState, - decodedURI = decodeURI(uri); - - cordova.exec(function (sandboxed) { - sandboxState = sandboxed; - }, function (e) { - console.log("[ERROR]: Could not retrieve sandbox state ", e); - }, "org.apache.cordova.file", "isSandboxed"); - - if (fileUtils.isOutsideSandbox(stripURI(decodedURI))) { - cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [false]); - } else { - cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [true]); - } - window.webkitResolveLocalFileSystemURL(decodedURI, function (entry) { - success(fileUtils.createEntry(entry)); - }, function (e) { - window.webkitResolveLocalFileSystemURL(decodedURI + '/', function (entry) { - success(fileUtils.createEntry(entry)); - }, function (e) { - fail(e); - }); - }); - cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [sandboxState]); -}; |
