summaryrefslogtreecommitdiff
path: root/plugins/cordova-plugin-file/www/blackberry10
diff options
context:
space:
mode:
authorPliablePixels <pliablepixels@gmail.com>2015-06-27 09:52:06 -0400
committerPliablePixels <pliablepixels@gmail.com>2015-06-27 09:52:06 -0400
commit319d4cb6670729708c19ad50b0146d1bcb7b4719 (patch)
treec61e9723a1fd217b1816c987bba66e470e73bf02 /plugins/cordova-plugin-file/www/blackberry10
parentfdc42fae48db0fef5fbdc9ef51a27d219aea3a72 (diff)
Added ability to log key events to file and email (useful for release debugging)
Diffstat (limited to 'plugins/cordova-plugin-file/www/blackberry10')
-rw-r--r--plugins/cordova-plugin-file/www/blackberry10/FileProxy.js51
-rw-r--r--plugins/cordova-plugin-file/www/blackberry10/FileSystem.js46
-rw-r--r--plugins/cordova-plugin-file/www/blackberry10/copyTo.js141
-rw-r--r--plugins/cordova-plugin-file/www/blackberry10/createEntryFromNative.js77
-rw-r--r--plugins/cordova-plugin-file/www/blackberry10/getDirectory.js72
-rw-r--r--plugins/cordova-plugin-file/www/blackberry10/getFile.js57
-rw-r--r--plugins/cordova-plugin-file/www/blackberry10/getFileMetadata.js65
-rw-r--r--plugins/cordova-plugin-file/www/blackberry10/getMetadata.js54
-rw-r--r--plugins/cordova-plugin-file/www/blackberry10/getParent.js57
-rw-r--r--plugins/cordova-plugin-file/www/blackberry10/info.js52
-rw-r--r--plugins/cordova-plugin-file/www/blackberry10/moveTo.js39
-rw-r--r--plugins/cordova-plugin-file/www/blackberry10/readAsArrayBuffer.js68
-rw-r--r--plugins/cordova-plugin-file/www/blackberry10/readAsBinaryString.js68
-rw-r--r--plugins/cordova-plugin-file/www/blackberry10/readAsDataURL.js65
-rw-r--r--plugins/cordova-plugin-file/www/blackberry10/readAsText.js77
-rw-r--r--plugins/cordova-plugin-file/www/blackberry10/readEntries.js71
-rw-r--r--plugins/cordova-plugin-file/www/blackberry10/remove.js61
-rw-r--r--plugins/cordova-plugin-file/www/blackberry10/removeRecursively.js62
-rw-r--r--plugins/cordova-plugin-file/www/blackberry10/requestAllFileSystems.js42
-rw-r--r--plugins/cordova-plugin-file/www/blackberry10/requestAnimationFrame.js38
-rw-r--r--plugins/cordova-plugin-file/www/blackberry10/requestFileSystem.js53
-rw-r--r--plugins/cordova-plugin-file/www/blackberry10/resolveLocalFileSystemURI.js172
-rw-r--r--plugins/cordova-plugin-file/www/blackberry10/setMetadata.js33
-rw-r--r--plugins/cordova-plugin-file/www/blackberry10/truncate.js74
-rw-r--r--plugins/cordova-plugin-file/www/blackberry10/write.js73
25 files changed, 1668 insertions, 0 deletions
diff --git a/plugins/cordova-plugin-file/www/blackberry10/FileProxy.js b/plugins/cordova-plugin-file/www/blackberry10/FileProxy.js
new file mode 100644
index 00000000..bd286cb9
--- /dev/null
+++ b/plugins/cordova-plugin-file/www/blackberry10/FileProxy.js
@@ -0,0 +1,51 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+/*
+ * FileProxy
+ *
+ * Register all File exec calls to be handled by proxy
+ */
+
+module.exports = {
+ copyTo: require('cordova-plugin-file.copyToProxy'),
+ getDirectory: require('cordova-plugin-file.getDirectoryProxy'),
+ getFile: require('cordova-plugin-file.getFileProxy'),
+ getFileMetadata: require('cordova-plugin-file.getFileMetadataProxy'),
+ getMetadata: require('cordova-plugin-file.getMetadataProxy'),
+ getParent: require('cordova-plugin-file.getParentProxy'),
+ moveTo: require('cordova-plugin-file.moveToProxy'),
+ readAsArrayBuffer: require('cordova-plugin-file.readAsArrayBufferProxy'),
+ readAsBinaryString: require('cordova-plugin-file.readAsBinaryStringProxy'),
+ readAsDataURL: require('cordova-plugin-file.readAsDataURLProxy'),
+ readAsText: require('cordova-plugin-file.readAsTextProxy'),
+ readEntries: require('cordova-plugin-file.readEntriesProxy'),
+ remove: require('cordova-plugin-file.removeProxy'),
+ removeRecursively: require('cordova-plugin-file.removeRecursivelyProxy'),
+ resolveLocalFileSystemURI: require('cordova-plugin-file.resolveLocalFileSystemURIProxy'),
+ requestAllFileSystems: require('cordova-plugin-file.requestAllFileSystemsProxy'),
+ requestFileSystem: require('cordova-plugin-file.requestFileSystemProxy'),
+ setMetadata: require('cordova-plugin-file.setMetadataProxy'),
+ truncate: require('cordova-plugin-file.truncateProxy'),
+ write: require('cordova-plugin-file.writeProxy')
+};
+
+require('cordova/exec/proxy').add('File', module.exports);
diff --git a/plugins/cordova-plugin-file/www/blackberry10/FileSystem.js b/plugins/cordova-plugin-file/www/blackberry10/FileSystem.js
new file mode 100644
index 00000000..59a1fac8
--- /dev/null
+++ b/plugins/cordova-plugin-file/www/blackberry10/FileSystem.js
@@ -0,0 +1,46 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+/*
+ * FileSystem
+ *
+ * Translate temporary / persistent / root file paths
+ */
+
+var info = require("cordova-plugin-file.bb10FileSystemInfo");
+
+module.exports = {
+ __format__: function(fullPath) {
+ switch (this.name) {
+ case 'temporary':
+ path = info.temporaryPath + fullPath;
+ break;
+ case 'persistent':
+ path = info.persistentPath + fullPath;
+ break;
+ case 'root':
+ path = 'file://' + fullPath;
+ break;
+ }
+ return window.encodeURI(path);
+ }
+};
+
diff --git a/plugins/cordova-plugin-file/www/blackberry10/copyTo.js b/plugins/cordova-plugin-file/www/blackberry10/copyTo.js
new file mode 100644
index 00000000..f27bf54e
--- /dev/null
+++ b/plugins/cordova-plugin-file/www/blackberry10/copyTo.js
@@ -0,0 +1,141 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+/*
+ * copyTo
+ *
+ * IN:
+ * args
+ * 0 - URL of entry to copy
+ * 1 - URL of the directory into which to copy/move the entry
+ * 2 - the new name of the entry, defaults to the current name
+ * move - if true, delete the entry which was copied
+ * OUT:
+ * success - entry for the copied file or directory
+ * fail - FileError
+ */
+
+var resolve = cordova.require('cordova-plugin-file.resolveLocalFileSystemURIProxy'),
+ requestAnimationFrame = cordova.require('cordova-plugin-file.bb10RequestAnimationFrame');
+
+module.exports = function (success, fail, args, move) {
+ var uri = args[0],
+ destination = args[1],
+ fileName = args[2],
+ copiedEntry,
+ onSuccess = function () {
+ resolve(
+ function (entry) {
+ if (typeof(success) === 'function') {
+ success(entry);
+ }
+ },
+ onFail,
+ [destination + copiedEntry.name]
+ );
+ },
+ onFail = function (error) {
+ if (typeof(fail) === 'function') {
+ if (error && error.code) {
+ //set error codes expected by mobile spec
+ if (uri === destination) {
+ fail(FileError.INVALID_MODIFICATION_ERR);
+ } else if (error.code === FileError.SECURITY_ERR) {
+ fail(FileError.INVALID_MODIFICATION_ERR);
+ } else {
+ fail(error.code);
+ }
+ } else {
+ fail(error);
+ }
+ }
+ },
+ writeFile = function (fileEntry, blob, entry) {
+ copiedEntry = fileEntry;
+ fileEntry.createWriter(function (fileWriter) {
+ fileWriter.onwriteend = function () {
+ if (move) {
+ entry.nativeEntry.remove(onSuccess, function () {
+ console.error("Move operation failed. Files may exist at both source and destination");
+ });
+ } else {
+ onSuccess();
+ }
+ };
+ fileWriter.onerror = onFail;
+ fileWriter.write(blob);
+ }, onFail);
+ },
+ copyFile = function (entry) {
+ if (entry.nativeEntry.file) {
+ entry.nativeEntry.file(function (file) {
+ var reader = new FileReader()._realReader;
+ reader.onloadend = function (e) {
+ var contents = new Uint8Array(this.result),
+ blob = new Blob([contents]);
+ resolve(function (destEntry) {
+ requestAnimationFrame(function () {
+ destEntry.nativeEntry.getFile(fileName, {create: true}, function (fileEntry) {
+ writeFile(fileEntry, blob, entry);
+ }, onFail);
+ });
+ }, onFail, [destination]);
+ };
+ reader.onerror = onFail;
+ reader.readAsArrayBuffer(file);
+ }, onFail);
+ } else {
+ onFail(FileError.INVALID_MODIFICATION_ERR);
+ }
+ },
+ copyDirectory = function (entry) {
+ resolve(function (destEntry) {
+ if (entry.filesystemName !== destEntry.filesystemName) {
+ console.error("Copying directories between filesystems is not supported on BB10");
+ onFail(FileError.INVALID_MODIFICATION_ERR);
+ } else {
+ entry.nativeEntry.copyTo(destEntry.nativeEntry, fileName, function () {
+ resolve(function (copiedDir) {
+ copiedEntry = copiedDir;
+ if (move) {
+ entry.nativeEntry.removeRecursively(onSuccess, onFail);
+ } else {
+ onSuccess();
+ }
+ }, onFail, [destination + fileName]);
+ }, onFail);
+ }
+ }, onFail, [destination]);
+ };
+ if (destination + fileName === uri) {
+ onFail(FileError.INVALID_MODIFICATION_ERR);
+ } else if (fileName.indexOf(':') > -1) {
+ onFail(FileError.ENCODING_ERR);
+ } else {
+ resolve(function (entry) {
+ if (entry.isDirectory) {
+ copyDirectory(entry);
+ } else {
+ copyFile(entry);
+ }
+ }, onFail, [uri]);
+ }
+};
diff --git a/plugins/cordova-plugin-file/www/blackberry10/createEntryFromNative.js b/plugins/cordova-plugin-file/www/blackberry10/createEntryFromNative.js
new file mode 100644
index 00000000..e1e042ac
--- /dev/null
+++ b/plugins/cordova-plugin-file/www/blackberry10/createEntryFromNative.js
@@ -0,0 +1,77 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+/*
+ * createEntryFromNative
+ *
+ * IN
+ * native - webkit Entry
+ * OUT
+ * returns Cordova entry
+ */
+
+var info = require('cordova-plugin-file.bb10FileSystemInfo'),
+ fileSystems = require('cordova-plugin-file.fileSystems');
+
+module.exports = function (native) {
+ var entry = {
+ nativeEntry: native,
+ isDirectory: !!native.isDirectory,
+ isFile: !!native.isFile,
+ name: native.name,
+ fullPath: native.fullPath,
+ filesystemName: native.filesystem.name,
+ nativeURL: native.toURL()
+ },
+ persistentPath = info.persistentPath.substring(7),
+ temporaryPath = info.temporaryPath.substring(7);
+ //fix bb10 webkit incorrect nativeURL
+ if (native.filesystem.name === 'root') {
+ entry.nativeURL = 'file:///' + native.fullPath;
+ } else if (entry.nativeURL.indexOf('filesystem:local:///persistent/') === 0) {
+ entry.nativeURL = info.persistentPath + native.fullPath;
+ } else if (entry.nativeURL.indexOf('filesystem:local:///temporary') === 0) {
+ entry.nativeURL = info.temporaryPath + native.fullPath;
+ }
+ //translate file system name from bb10 webkit
+ if (entry.filesystemName === 'local__0:Persistent' || entry.fullPath.indexOf(persistentPath) !== -1) {
+ entry.filesystemName = 'persistent';
+ } else if (entry.filesystemName === 'local__0:Temporary' || entry.fullPath.indexOf(temporaryPath) !== -1) {
+ entry.filesystemName = 'temporary';
+ }
+ //add file system property (will be called sync)
+ fileSystems.getFs(entry.filesystemName, function (fs) {
+ entry.filesystem = fs;
+ });
+ //set root on fullPath for persistent / temporary locations
+ entry.fullPath = entry.fullPath.replace(persistentPath, "");
+ entry.fullPath = entry.fullPath.replace(temporaryPath, "");
+ //set trailing slash on directory
+ if (entry.isDirectory && entry.fullPath.substring(entry.fullPath.length - 1) !== '/') {
+ entry.fullPath += '/';
+ }
+ if (entry.isDirectory && entry.nativeURL.substring(entry.nativeURL.length - 1) !== '/') {
+ entry.nativeURL += '/';
+ }
+ //encode URL
+ entry.nativeURL = window.encodeURI(entry.nativeURL);
+ return entry;
+};
diff --git a/plugins/cordova-plugin-file/www/blackberry10/getDirectory.js b/plugins/cordova-plugin-file/www/blackberry10/getDirectory.js
new file mode 100644
index 00000000..95c84c7a
--- /dev/null
+++ b/plugins/cordova-plugin-file/www/blackberry10/getDirectory.js
@@ -0,0 +1,72 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+/*
+ * getDirectory
+ *
+ * IN:
+ * args
+ * 0 - local filesytem URI for the base directory to search
+ * 1 - directory to be created/returned; may be absolute path or relative path
+ * 2 - options object
+ * OUT:
+ * success - DirectoryEntry
+ * fail - FileError code
+ */
+
+var resolve = cordova.require('cordova-plugin-file.resolveLocalFileSystemURIProxy'),
+ requestAnimationFrame = cordova.require('cordova-plugin-file.bb10RequestAnimationFrame');
+
+module.exports = function (success, fail, args) {
+ var uri = args[0] === "/" ? "" : args[0],
+ dir = args[1],
+ options = args[2],
+ onSuccess = function (entry) {
+ if (typeof(success) === 'function') {
+ success(entry);
+ }
+ },
+ onFail = function (error) {
+ if (typeof(fail) === 'function') {
+ if (error && error.code) {
+ //set error codes expected by mobile-spec tests
+ if (error.code === FileError.INVALID_MODIFICATION_ERR && options.exclusive) {
+ fail(FileError.PATH_EXISTS_ERR);
+ } else if ( error.code === FileError.NOT_FOUND_ERR && dir.indexOf(':') > 0) {
+ fail(FileError.ENCODING_ERR);
+ } else {
+ fail(error.code);
+ }
+ } else {
+ fail(error);
+ }
+ }
+ };
+ resolve(function (entry) {
+ requestAnimationFrame(function () {
+ entry.nativeEntry.getDirectory(dir, options, function (nativeEntry) {
+ resolve(function (entry) {
+ onSuccess(entry);
+ }, onFail, [uri + "/" + dir]);
+ }, onFail);
+ });
+ }, onFail, [uri]);
+};
diff --git a/plugins/cordova-plugin-file/www/blackberry10/getFile.js b/plugins/cordova-plugin-file/www/blackberry10/getFile.js
new file mode 100644
index 00000000..1a730ae7
--- /dev/null
+++ b/plugins/cordova-plugin-file/www/blackberry10/getFile.js
@@ -0,0 +1,57 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+/*
+ * getFile
+ *
+ * IN:
+ * args
+ * 0 - local filesytem URI for the base directory to search
+ * 1 - file to be created/returned; may be absolute path or relative path
+ * 2 - options object
+ * OUT:
+ * success - FileEntry
+ * fail - FileError code
+ */
+
+var resolve = cordova.require('cordova-plugin-file.resolveLocalFileSystemURIProxy');
+
+module.exports = function (success, fail, args) {
+ var uri = args[0] === "/" ? "" : args[0] + "/" + args[1],
+ options = args[2],
+ onSuccess = function (entry) {
+ if (typeof(success) === 'function') {
+ success(entry);
+ }
+ },
+ onFail = function (code) {
+ if (typeof(fail) === 'function') {
+ fail(code);
+ }
+ };
+ resolve(function (entry) {
+ if (!entry.isFile) {
+ onFail(FileError.TYPE_MISMATCH_ERR);
+ } else {
+ onSuccess(entry);
+ }
+ }, onFail, [uri, options]);
+};
diff --git a/plugins/cordova-plugin-file/www/blackberry10/getFileMetadata.js b/plugins/cordova-plugin-file/www/blackberry10/getFileMetadata.js
new file mode 100644
index 00000000..3383e035
--- /dev/null
+++ b/plugins/cordova-plugin-file/www/blackberry10/getFileMetadata.js
@@ -0,0 +1,65 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+/*
+ * getFileMetadata
+ *
+ * IN:
+ * args
+ * 0 - local filesytem URI
+ * OUT:
+ * success - file
+ * - name
+ * - type
+ * - lastModifiedDate
+ * - size
+ * fail - FileError code
+ */
+
+var resolve = cordova.require('cordova-plugin-file.resolveLocalFileSystemURIProxy'),
+ requestAnimationFrame = cordova.require('cordova-plugin-file.bb10RequestAnimationFrame');
+
+module.exports = function (success, fail, args) {
+ var uri = args[0],
+ onSuccess = function (entry) {
+ if (typeof(success) === 'function') {
+ success(entry);
+ }
+ },
+ onFail = function (error) {
+ if (typeof(fail) === 'function') {
+ if (error.code) {
+ fail(error.code);
+ } else {
+ fail(error);
+ }
+ }
+ };
+ resolve(function (entry) {
+ requestAnimationFrame(function () {
+ if (entry.nativeEntry.file) {
+ entry.nativeEntry.file(onSuccess, onFail);
+ } else {
+ entry.nativeEntry.getMetadata(onSuccess, onFail);
+ }
+ });
+ }, onFail, [uri]);
+};
diff --git a/plugins/cordova-plugin-file/www/blackberry10/getMetadata.js b/plugins/cordova-plugin-file/www/blackberry10/getMetadata.js
new file mode 100644
index 00000000..3dd5c02c
--- /dev/null
+++ b/plugins/cordova-plugin-file/www/blackberry10/getMetadata.js
@@ -0,0 +1,54 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+/*
+ * getMetadata
+ *
+ * IN:
+ * args
+ * 0 - local filesytem URI
+ * OUT:
+ * success - metadata
+ * fail - FileError code
+ */
+
+var resolve = cordova.require('cordova-plugin-file.resolveLocalFileSystemURIProxy');
+
+module.exports = function (success, fail, args) {
+ var uri = args[0],
+ onSuccess = function (entry) {
+ if (typeof(success) === 'function') {
+ success(entry);
+ }
+ },
+ onFail = function (error) {
+ if (typeof(fail) === 'function') {
+ if (error.code) {
+ fail(error.code);
+ } else {
+ fail(error);
+ }
+ }
+ };
+ resolve(function (entry) {
+ entry.nativeEntry.getMetadata(onSuccess, onFail);
+ }, onFail, [uri]);
+};
diff --git a/plugins/cordova-plugin-file/www/blackberry10/getParent.js b/plugins/cordova-plugin-file/www/blackberry10/getParent.js
new file mode 100644
index 00000000..dd5e3547
--- /dev/null
+++ b/plugins/cordova-plugin-file/www/blackberry10/getParent.js
@@ -0,0 +1,57 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+/*
+ * getParent
+ *
+ * IN:
+ * args
+ * 0 - local filesytem URI
+ * OUT:
+ * success - DirectoryEntry of parent
+ * fail - FileError code
+ */
+
+var resolve = cordova.require('cordova-plugin-file.resolveLocalFileSystemURIProxy'),
+ requestAnimationFrame = cordova.require('cordova-plugin-file.bb10RequestAnimationFrame');
+
+module.exports = function (success, fail, args) {
+ var uri = args[0],
+ onSuccess = function (entry) {
+ if (typeof(success) === 'function') {
+ success(entry);
+ }
+ },
+ onFail = function (error) {
+ if (typeof(fail) === 'function') {
+ if (error && error.code) {
+ fail(error.code);
+ } else {
+ fail(error);
+ }
+ }
+ };
+ resolve(function (entry) {
+ requestAnimationFrame(function () {
+ entry.nativeEntry.getParent(onSuccess, onFail);
+ });
+ }, onFail, [uri]);
+};
diff --git a/plugins/cordova-plugin-file/www/blackberry10/info.js b/plugins/cordova-plugin-file/www/blackberry10/info.js
new file mode 100644
index 00000000..feaccd91
--- /dev/null
+++ b/plugins/cordova-plugin-file/www/blackberry10/info.js
@@ -0,0 +1,52 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+/*
+ * info
+ *
+ * persistentPath - full path to app sandboxed persistent storage
+ * temporaryPath - full path to app sandboxed temporary storage
+ * localPath - full path to app source (www dir)
+ * MAX_SIZE - maximum size for filesystem request
+ */
+
+var info = {
+ persistentPath: "",
+ temporaryPath: "",
+ localPath: "",
+ MAX_SIZE: 64 * 1024 * 1024 * 1024
+};
+
+cordova.exec(
+ function (path) {
+ info.persistentPath = 'file://' + path + '/webviews/webfs/persistent/local__0';
+ info.temporaryPath = 'file://' + path + '/webviews/webfs/temporary/local__0';
+ info.localPath = path.replace('/data', '/app/native');
+ },
+ function () {
+ console.error('Unable to determine local storage file path');
+ },
+ 'File',
+ 'getHomePath',
+ false
+);
+
+module.exports = info;
diff --git a/plugins/cordova-plugin-file/www/blackberry10/moveTo.js b/plugins/cordova-plugin-file/www/blackberry10/moveTo.js
new file mode 100644
index 00000000..f6560e8a
--- /dev/null
+++ b/plugins/cordova-plugin-file/www/blackberry10/moveTo.js
@@ -0,0 +1,39 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+/*
+ * moveTo
+ *
+ * IN:
+ * args
+ * 0 - URL of entry to move
+ * 1 - URL of the directory into which to move the entry
+ * 2 - the new name of the entry, defaults to the current name
+ * OUT:
+ * success - entry for the copied file or directory
+ * fail - FileError
+ */
+
+var copy = cordova.require('cordova-plugin-file.copyToProxy');
+
+module.exports = function (success, fail, args) {
+ copy(success, fail, args, true);
+};
diff --git a/plugins/cordova-plugin-file/www/blackberry10/readAsArrayBuffer.js b/plugins/cordova-plugin-file/www/blackberry10/readAsArrayBuffer.js
new file mode 100644
index 00000000..41c677a2
--- /dev/null
+++ b/plugins/cordova-plugin-file/www/blackberry10/readAsArrayBuffer.js
@@ -0,0 +1,68 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+/*
+ * readAsArrayBuffer
+ *
+ * IN:
+ * args
+ * 0 - URL of file to read
+ * 1 - start position
+ * 2 - end position
+ * OUT:
+ * success - ArrayBuffer of file
+ * fail - FileError
+ */
+
+var resolve = cordova.require('cordova-plugin-file.resolveLocalFileSystemURIProxy'),
+ requestAnimationFrame = cordova.require('cordova-plugin-file.bb10RequestAnimationFrame');
+
+module.exports = function (success, fail, args) {
+ var uri = args[0],
+ start = args[1],
+ end = args[2],
+ onSuccess = function (data) {
+ if (typeof success === 'function') {
+ success(data);
+ }
+ },
+ onFail = function (error) {
+ if (typeof fail === 'function') {
+ if (error && error.code) {
+ fail(error.code);
+ } else {
+ fail(error);
+ }
+ }
+ };
+ resolve(function (fs) {
+ requestAnimationFrame(function () {
+ fs.nativeEntry.file(function (file) {
+ var reader = new FileReader()._realReader;
+ reader.onloadend = function () {
+ onSuccess(this.result.slice(start, end));
+ };
+ reader.onerror = onFail;
+ reader.readAsArrayBuffer(file);
+ }, onFail);
+ });
+ }, fail, [uri]);
+};
diff --git a/plugins/cordova-plugin-file/www/blackberry10/readAsBinaryString.js b/plugins/cordova-plugin-file/www/blackberry10/readAsBinaryString.js
new file mode 100644
index 00000000..6a70f1a2
--- /dev/null
+++ b/plugins/cordova-plugin-file/www/blackberry10/readAsBinaryString.js
@@ -0,0 +1,68 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+/*
+ * readAsBinaryString
+ *
+ * IN:
+ * args
+ * 0 - URL of file to read
+ * 1 - start position
+ * 2 - end position
+ * OUT:
+ * success - BinaryString contents of file
+ * fail - FileError
+ */
+
+var resolve = cordova.require('cordova-plugin-file.resolveLocalFileSystemURIProxy'),
+ requestAnimationFrame = cordova.require('cordova-plugin-file.bb10RequestAnimationFrame');
+
+module.exports = function (success, fail, args) {
+ var uri = args[0],
+ start = args[1],
+ end = args[2],
+ onSuccess = function (data) {
+ if (typeof success === 'function') {
+ success(data);
+ }
+ },
+ onFail = function (error) {
+ if (typeof fail === 'function') {
+ if (error && error.code) {
+ fail(error.code);
+ } else {
+ fail(error);
+ }
+ }
+ };
+ resolve(function (fs) {
+ requestAnimationFrame(function () {
+ fs.nativeEntry.file(function (file) {
+ var reader = new FileReader()._realReader;
+ reader.onloadend = function () {
+ onSuccess(this.result.substring(start, end));
+ };
+ reader.onerror = onFail;
+ reader.readAsBinaryString(file);
+ }, onFail);
+ });
+ }, fail, [uri]);
+};
diff --git a/plugins/cordova-plugin-file/www/blackberry10/readAsDataURL.js b/plugins/cordova-plugin-file/www/blackberry10/readAsDataURL.js
new file mode 100644
index 00000000..0256c5ec
--- /dev/null
+++ b/plugins/cordova-plugin-file/www/blackberry10/readAsDataURL.js
@@ -0,0 +1,65 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+/*
+ * readAsDataURL
+ *
+ * IN:
+ * args
+ * 0 - URL of file to read
+ * OUT:
+ * success - DataURL representation of file contents
+ * fail - FileError
+ */
+
+
+var resolve = cordova.require('cordova-plugin-file.resolveLocalFileSystemURIProxy'),
+ requestAnimationFrame = cordova.require('cordova-plugin-file.bb10RequestAnimationFrame');
+
+module.exports = function (success, fail, args) {
+ var uri = args[0],
+ onSuccess = function (data) {
+ if (typeof success === 'function') {
+ success(data);
+ }
+ },
+ onFail = function (error) {
+ if (typeof fail === 'function') {
+ if (error && error.code) {
+ fail(error.code);
+ } else {
+ fail(error);
+ }
+ }
+ };
+ resolve(function (fs) {
+ requestAnimationFrame(function () {
+ fs.nativeEntry.file(function (file) {
+ var reader = new FileReader()._realReader;
+ reader.onloadend = function () {
+ onSuccess(this.result);
+ };
+ reader.onerror = onFail;
+ reader.readAsDataURL(file);
+ }, onFail);
+ });
+ }, fail, [uri]);
+};
diff --git a/plugins/cordova-plugin-file/www/blackberry10/readAsText.js b/plugins/cordova-plugin-file/www/blackberry10/readAsText.js
new file mode 100644
index 00000000..7809a908
--- /dev/null
+++ b/plugins/cordova-plugin-file/www/blackberry10/readAsText.js
@@ -0,0 +1,77 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+/*
+ * readAsText
+ *
+ * IN:
+ * args
+ * 0 - URL of file to read
+ * 1 - encoding
+ * 2 - start position
+ * 3 - end position
+ * OUT:
+ * success - text contents of file
+ * fail - FileError
+ */
+
+
+var resolve = cordova.require('cordova-plugin-file.resolveLocalFileSystemURIProxy'),
+ requestAnimationFrame = cordova.require('cordova-plugin-file.bb10RequestAnimationFrame');
+
+module.exports = function (success, fail, args) {
+ var uri = args[0],
+ start = args[2],
+ end = args[3],
+ onSuccess = function (data) {
+ if (typeof success === 'function') {
+ success(data);
+ }
+ },
+ onFail = function (error) {
+ if (typeof fail === 'function') {
+ if (error && error.code) {
+ fail(error.code);
+ } else {
+ fail(error);
+ }
+ }
+ };
+ resolve(function (fs) {
+ requestAnimationFrame(function () {
+ fs.nativeEntry.file(function (file) {
+ var reader = new FileReader()._realReader;
+ reader.onloadend = function () {
+ var contents = new Uint8Array(this.result).subarray(start, end),
+ blob = new Blob([contents]),
+ textReader = new FileReader()._realReader;
+ textReader.onloadend = function () {
+ onSuccess(this.result);
+ };
+ textReader.onerror = onFail;
+ textReader.readAsText(blob);
+ };
+ reader.onerror = onFail;
+ reader.readAsArrayBuffer(file);
+ }, onFail);
+ });
+ }, fail, [uri]);
+};
diff --git a/plugins/cordova-plugin-file/www/blackberry10/readEntries.js b/plugins/cordova-plugin-file/www/blackberry10/readEntries.js
new file mode 100644
index 00000000..5284d77b
--- /dev/null
+++ b/plugins/cordova-plugin-file/www/blackberry10/readEntries.js
@@ -0,0 +1,71 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+/*
+ * readEntries
+ *
+ * IN:
+ * args
+ * 0 - URL of directory to list
+ * OUT:
+ * success - Array of Entry objects
+ * fail - FileError
+ */
+
+var resolve = cordova.require('cordova-plugin-file.resolveLocalFileSystemURIProxy'),
+ info = require('cordova-plugin-file.bb10FileSystemInfo'),
+ requestAnimationFrame = cordova.require('cordova-plugin-file.bb10RequestAnimationFrame'),
+ createEntryFromNative = cordova.require('cordova-plugin-file.bb10CreateEntryFromNative');
+
+module.exports = function (success, fail, args) {
+ var uri = args[0],
+ onSuccess = function (data) {
+ if (typeof success === 'function') {
+ success(data);
+ }
+ },
+ onFail = function (error) {
+ if (typeof fail === 'function') {
+ if (error.code) {
+ fail(error.code);
+ } else {
+ fail(error);
+ }
+ }
+ };
+ resolve(function (fs) {
+ requestAnimationFrame(function () {
+ var reader = fs.nativeEntry.createReader(),
+ entries = [],
+ readEntries = function() {
+ reader.readEntries(function (results) {
+ if (!results.length) {
+ onSuccess(entries.sort().map(createEntryFromNative));
+ } else {
+ entries = entries.concat(Array.prototype.slice.call(results || [], 0));
+ readEntries();
+ }
+ }, onFail);
+ };
+ readEntries();
+ });
+ }, fail, [uri]);
+};
diff --git a/plugins/cordova-plugin-file/www/blackberry10/remove.js b/plugins/cordova-plugin-file/www/blackberry10/remove.js
new file mode 100644
index 00000000..f57973ae
--- /dev/null
+++ b/plugins/cordova-plugin-file/www/blackberry10/remove.js
@@ -0,0 +1,61 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+/*
+ * remove
+ *
+ * IN:
+ * args
+ * 0 - URL of Entry to remove
+ * OUT:
+ * success - (no args)
+ * fail - FileError
+ */
+
+var resolve = cordova.require('cordova-plugin-file.resolveLocalFileSystemURIProxy'),
+ requestAnimationFrame = cordova.require('cordova-plugin-file.bb10RequestAnimationFrame');
+
+module.exports = function (success, fail, args) {
+ var uri = args[0],
+ onSuccess = function (data) {
+ if (typeof success === 'function') {
+ success(data);
+ }
+ },
+ onFail = function (error) {
+ if (typeof fail === 'function') {
+ if (error && error.code) {
+ fail(error.code);
+ } else {
+ fail(error);
+ }
+ }
+ };
+ resolve(function (fs) {
+ requestAnimationFrame(function () {
+ if (fs.fullPath === '/') {
+ onFail(FileError.NO_MODIFICATION_ALLOWED_ERR);
+ } else {
+ fs.nativeEntry.remove(onSuccess, onFail);
+ }
+ });
+ }, fail, [uri]);
+};
diff --git a/plugins/cordova-plugin-file/www/blackberry10/removeRecursively.js b/plugins/cordova-plugin-file/www/blackberry10/removeRecursively.js
new file mode 100644
index 00000000..93b559bd
--- /dev/null
+++ b/plugins/cordova-plugin-file/www/blackberry10/removeRecursively.js
@@ -0,0 +1,62 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+/*
+ * removeRecursively
+ *
+ * IN:
+ * args
+ * 0 - URL of DirectoryEntry to remove recursively
+ * OUT:
+ * success - (no args)
+ * fail - FileError
+ */
+
+var resolve = cordova.require('cordova-plugin-file.resolveLocalFileSystemURIProxy'),
+ requestAnimationFrame = cordova.require('cordova-plugin-file.bb10RequestAnimationFrame');
+
+module.exports = function (success, fail, args) {
+ var uri = args[0],
+ onSuccess = function (data) {
+ if (typeof success === 'function') {
+ success(data);
+ }
+ },
+ onFail = function (error) {
+ if (typeof fail === 'function') {
+ if (error.code) {
+ if (error.code === FileError.INVALID_MODIFICATION_ERR) {
+ //mobile-spec expects this error code
+ fail(FileError.NO_MODIFICATION_ALLOWED_ERR);
+ } else {
+ fail(error.code);
+ }
+ } else {
+ fail(error);
+ }
+ }
+ };
+ resolve(function (fs) {
+ requestAnimationFrame(function () {
+ fs.nativeEntry.removeRecursively(onSuccess, onFail);
+ });
+ }, fail, [uri]);
+};
diff --git a/plugins/cordova-plugin-file/www/blackberry10/requestAllFileSystems.js b/plugins/cordova-plugin-file/www/blackberry10/requestAllFileSystems.js
new file mode 100644
index 00000000..8354ab1c
--- /dev/null
+++ b/plugins/cordova-plugin-file/www/blackberry10/requestAllFileSystems.js
@@ -0,0 +1,42 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+/*
+ * requestAllFileSystems
+ *
+ * IN - no arguments
+ * OUT
+ * success - Array of FileSystems
+ * - filesystemName
+ * - fullPath
+ * - name
+ * - nativeURL
+ */
+
+var info = require('cordova-plugin-file.bb10FileSystemInfo');
+
+module.exports = function (success, fail, args) {
+ success([
+ { filesystemName: 'persistent', name: 'persistent', fullPath: '/', nativeURL: info.persistentPath + '/' },
+ { filesystemName: 'temporary', name: 'temporary', fullPath: '/', nativeURL: info.temporaryPath + '/' },
+ { filesystemName: 'root', name: 'root', fullPath: '/', nativeURL: 'file:///' }
+ ]);
+}
diff --git a/plugins/cordova-plugin-file/www/blackberry10/requestAnimationFrame.js b/plugins/cordova-plugin-file/www/blackberry10/requestAnimationFrame.js
new file mode 100644
index 00000000..6c3288cc
--- /dev/null
+++ b/plugins/cordova-plugin-file/www/blackberry10/requestAnimationFrame.js
@@ -0,0 +1,38 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+/*
+ * requestAnimationFrame
+ *
+ * This is used throughout the BB10 File implementation to wrap
+ * native webkit calls. There is a bug in the webkit implementation
+ * which causes callbacks to never return when multiple file system
+ * APIs are called in sequence. This should also make the UI more
+ * responsive during file operations.
+ *
+ * Supported on BB10 OS > 10.1
+ */
+
+var requestAnimationFrame = window.requestAnimationFrame;
+if (typeof(requestAnimationFrame) !== 'function') {
+ requestAnimationFrame = function (cb) { cb(); };
+}
+module.exports = requestAnimationFrame;
diff --git a/plugins/cordova-plugin-file/www/blackberry10/requestFileSystem.js b/plugins/cordova-plugin-file/www/blackberry10/requestFileSystem.js
new file mode 100644
index 00000000..f02edbf5
--- /dev/null
+++ b/plugins/cordova-plugin-file/www/blackberry10/requestFileSystem.js
@@ -0,0 +1,53 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+/*
+ * requestFileSystem
+ *
+ * IN:
+ * args
+ * 0 - type (TEMPORARY = 0, PERSISTENT = 1)
+ * 1 - size
+ * OUT:
+ * success - FileSystem object
+ * - name - the human readable directory name
+ * - root - DirectoryEntry object
+ * - isDirectory
+ * - isFile
+ * - name
+ * - fullPath
+ * fail - FileError code
+ */
+
+var resolve = cordova.require('cordova-plugin-file.resolveLocalFileSystemURIProxy');
+
+module.exports = function (success, fail, args) {
+ var fsType = args[0] === 0 ? 'temporary' : 'persistent',
+ size = args[1],
+ onSuccess = function (fs) {
+ var directory = {
+ name: fsType,
+ root: fs
+ };
+ success(directory);
+ };
+ resolve(onSuccess, fail, ['cdvfile://localhost/' + fsType + '/', undefined, size]);
+};
diff --git a/plugins/cordova-plugin-file/www/blackberry10/resolveLocalFileSystemURI.js b/plugins/cordova-plugin-file/www/blackberry10/resolveLocalFileSystemURI.js
new file mode 100644
index 00000000..0fc9c070
--- /dev/null
+++ b/plugins/cordova-plugin-file/www/blackberry10/resolveLocalFileSystemURI.js
@@ -0,0 +1,172 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+/*
+ * resolveLocalFileSystemURI
+ *
+ * IN
+ * args
+ * 0 - escaped local filesystem URI
+ * 1 - options (standard HTML5 file system options)
+ * 2 - size
+ * OUT
+ * success - Entry object
+ * - isDirectory
+ * - isFile
+ * - name
+ * - fullPath
+ * - nativeURL
+ * - fileSystemName
+ * fail - FileError code
+ */
+
+var info = require('cordova-plugin-file.bb10FileSystemInfo'),
+ requestAnimationFrame = cordova.require('cordova-plugin-file.bb10RequestAnimationFrame'),
+ createEntryFromNative = require('cordova-plugin-file.bb10CreateEntryFromNative'),
+ SANDBOXED = true,
+ UNSANDBOXED = false;
+
+module.exports = function (success, fail, args) {
+ var request = args[0],
+ options = args[1],
+ size = args[2];
+ if (request) {
+ request = decodeURIComponent(request);
+ if (request.indexOf('?') > -1) {
+ //bb10 does not support params; strip them off
+ request = request.substring(0, request.indexOf('?'));
+ }
+ if (request.indexOf('file://localhost/') === 0) {
+ //remove localhost prefix
+ request = request.replace('file://localhost/', 'file:///');
+ }
+ //requests to sandboxed locations should use cdvfile
+ request = request.replace(info.persistentPath, 'cdvfile://localhost/persistent');
+ request = request.replace(info.temporaryPath, 'cdvfile://localhost/temporary');
+ //pick appropriate handler
+ if (request.indexOf('file:///') === 0) {
+ resolveFile(success, fail, request, options);
+ } else if (request.indexOf('cdvfile://localhost/') === 0) {
+ resolveCdvFile(success, fail, request, options, size);
+ } else if (request.indexOf('local:///') === 0) {
+ resolveLocal(success, fail, request, options);
+ } else {
+ fail(FileError.ENCODING_ERR);
+ }
+ } else {
+ fail(FileError.NOT_FOUND_ERR);
+ }
+};
+
+//resolve file:///
+function resolveFile(success, fail, request, options) {
+ var path = request.substring(7);
+ resolve(success, fail, path, window.PERSISTENT, UNSANDBOXED, options);
+}
+
+//resolve cdvfile://localhost/filesystemname/
+function resolveCdvFile(success, fail, request, options, size) {
+ var components = /cdvfile:\/\/localhost\/([^\/]+)\/(.*)/.exec(request),
+ fsType = components[1],
+ path = components[2];
+ if (fsType === 'persistent') {
+ resolve(success, fail, path, window.PERSISTENT, SANDBOXED, options, size);
+ }
+ else if (fsType === 'temporary') {
+ resolve(success, fail, path, window.TEMPORARY, SANDBOXED, options, size);
+ }
+ else if (fsType === 'root') {
+ resolve(success, fail, path, window.PERSISTENT, UNSANDBOXED, options);
+ }
+ else {
+ fail(FileError.NOT_FOUND_ERR);
+ }
+}
+
+//resolve local:///
+function resolveLocal(success, fail, request, options) {
+ var path = localPath + request.substring(8);
+ resolve(success, fail, path, window.PERSISTENT, UNSANDBOXED, options);
+}
+
+//validate parameters and set sandbox
+function resolve(success, fail, path, fsType, sandbox, options, size) {
+ options = options || { create: false };
+ size = size || info.MAX_SIZE;
+ if (size > info.MAX_SIZE) {
+ //bb10 does not respect quota; fail at unreasonably large size
+ fail(FileError.QUOTA_EXCEEDED_ERR);
+ } else if (path.indexOf(':') > -1) {
+ //files with : character are not valid in Cordova apps
+ fail(FileError.ENCODING_ERR);
+ } else {
+ requestAnimationFrame(function () {
+ cordova.exec(function () {
+ requestAnimationFrame(function () {
+ resolveNative(success, fail, path, fsType, options, size);
+ });
+ }, fail, 'File', 'setSandbox', [sandbox], false);
+ });
+ }
+}
+
+//find path using webkit file system
+function resolveNative(success, fail, path, fsType, options, size) {
+ window.webkitRequestFileSystem(
+ fsType,
+ size,
+ function (fs) {
+ if (path === '') {
+ //no path provided, call success with root file system
+ success(createEntryFromNative(fs.root));
+ } else {
+ //otherwise attempt to resolve as file
+ fs.root.getFile(
+ path,
+ options,
+ function (entry) {
+ success(createEntryFromNative(entry));
+ },
+ function (fileError) {
+ //file not found, attempt to resolve as directory
+ fs.root.getDirectory(
+ path,
+ options,
+ function (entry) {
+ success(createEntryFromNative(entry));
+ },
+ function (dirError) {
+ //path cannot be resolved
+ if (fileError.code === FileError.INVALID_MODIFICATION_ERR &&
+ options.exclusive) {
+ //mobile-spec expects this error code
+ fail(FileError.PATH_EXISTS_ERR);
+ } else {
+ fail(FileError.NOT_FOUND_ERR);
+ }
+ }
+ );
+ }
+ );
+ }
+ }
+ );
+}
diff --git a/plugins/cordova-plugin-file/www/blackberry10/setMetadata.js b/plugins/cordova-plugin-file/www/blackberry10/setMetadata.js
new file mode 100644
index 00000000..5254e868
--- /dev/null
+++ b/plugins/cordova-plugin-file/www/blackberry10/setMetadata.js
@@ -0,0 +1,33 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+/*
+ * setMetadata
+ *
+ * BB10 OS does not support setting file metadata via HTML5 File System
+ */
+
+module.exports = function (success, fail, args) {
+ console.error("setMetadata not supported on BB10", arguments);
+ if (typeof(fail) === 'function') {
+ fail();
+ }
+};
diff --git a/plugins/cordova-plugin-file/www/blackberry10/truncate.js b/plugins/cordova-plugin-file/www/blackberry10/truncate.js
new file mode 100644
index 00000000..ba7f77f1
--- /dev/null
+++ b/plugins/cordova-plugin-file/www/blackberry10/truncate.js
@@ -0,0 +1,74 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+/*
+ * truncate
+ *
+ * IN:
+ * args
+ * 0 - URL of file to truncate
+ * 1 - start position
+ * OUT:
+ * success - new length of file
+ * fail - FileError
+ */
+
+var resolve = cordova.require('cordova-plugin-file.resolveLocalFileSystemURIProxy'),
+ requestAnimationFrame = cordova.require('cordova-plugin-file.bb10RequestAnimationFrame');
+
+module.exports = function (success, fail, args) {
+ var uri = args[0],
+ length = args[1],
+ onSuccess = function (data) {
+ if (typeof success === 'function') {
+ success(data.loaded);
+ }
+ },
+ onFail = function (error) {
+ if (typeof fail === 'function') {
+ if (error && error.code) {
+ fail(error.code);
+ } else {
+ fail(error);
+ }
+ }
+ };
+ resolve(function (fs) {
+ requestAnimationFrame(function () {
+ fs.nativeEntry.file(function (file) {
+ var reader = new FileReader()._realReader;
+ reader.onloadend = function () {
+ var contents = new Uint8Array(this.result).subarray(0, length);
+ blob = new Blob([contents]);
+ window.requestAnimationFrame(function () {
+ fs.nativeEntry.createWriter(function (fileWriter) {
+ fileWriter.onwriteend = onSuccess;
+ fileWriter.onerror = onFail;
+ fileWriter.write(blob);
+ }, onFail);
+ });
+ };
+ reader.onerror = onFail;
+ reader.readAsArrayBuffer(file);
+ }, onFail);
+ });
+ }, onFail, [uri]);
+};
diff --git a/plugins/cordova-plugin-file/www/blackberry10/write.js b/plugins/cordova-plugin-file/www/blackberry10/write.js
new file mode 100644
index 00000000..386ec670
--- /dev/null
+++ b/plugins/cordova-plugin-file/www/blackberry10/write.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.
+ *
+*/
+
+/*
+ * write
+ *
+ * IN:
+ * args
+ * 0 - URL of file to write
+ * 1 - data to write
+ * 2 - offset
+ * 3 - isBinary
+ * OUT:
+ * success - bytes written
+ * fail - FileError
+ */
+
+var resolve = cordova.require('cordova-plugin-file.resolveLocalFileSystemURIProxy'),
+ requestAnimationFrame = cordova.require('cordova-plugin-file.bb10RequestAnimationFrame');
+
+module.exports = function (success, fail, args) {
+ var uri = args[0],
+ data = args[1],
+ offset = args[2],
+ isBinary = args[3],
+ onSuccess = function (data) {
+ if (typeof success === 'function') {
+ success(data.loaded);
+ }
+ },
+ onFail = function (error) {
+ if (typeof fail === 'function') {
+ if (error && error.code) {
+ fail(error.code);
+ } else if (error && error.target && error.target.code) {
+ fail(error.target.code);
+ } else {
+ fail(error);
+ }
+ }
+ };
+ resolve(function (fs) {
+ requestAnimationFrame(function () {
+ fs.nativeEntry.createWriter(function (writer) {
+ var blob = new Blob([data]);
+ if (offset) {
+ writer.seek(offset);
+ }
+ writer.onwriteend = onSuccess;
+ writer.onerror = onFail;
+ writer.write(blob);
+ }, onFail);
+ });
+ }, fail, [uri, { create: true }]);
+};