You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ti...@apache.org on 2012/05/18 00:37:08 UTC
[9/19] js commit: Added in resolveLocalFileSystemURI
Added in resolveLocalFileSystemURI
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/58943e2d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/58943e2d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/58943e2d
Branch: refs/heads/playbookFile
Commit: 58943e2d824124d9ac740c17d4f0eec1b965b6c5
Parents: a338d4b
Author: Tim Kim <ti...@adobe.com>
Authored: Wed May 9 18:35:28 2012 -0700
Committer: Tim Kim <ti...@adobe.com>
Committed: Wed May 9 18:35:28 2012 -0700
----------------------------------------------------------------------
lib/playbook/platform.js | 3 +
.../plugin/playbook/resolveLocalFileSystemURI.js | 55 +++++++++++++++
2 files changed, 58 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/58943e2d/lib/playbook/platform.js
----------------------------------------------------------------------
diff --git a/lib/playbook/platform.js b/lib/playbook/platform.js
index adabc6c..0b24e04 100644
--- a/lib/playbook/platform.js
+++ b/lib/playbook/platform.js
@@ -17,6 +17,9 @@ module.exports = {
requestFileSystem:{
path: 'cordova/plugin/playbook/requestFileSystem'
},
+ resolveLocalFileSystemURI:{
+ path: 'cordova/plugin/playbook/resolveLocalFileSystemURI'
+ },
},
merges: {
navigator: {
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/58943e2d/lib/playbook/plugin/playbook/resolveLocalFileSystemURI.js
----------------------------------------------------------------------
diff --git a/lib/playbook/plugin/playbook/resolveLocalFileSystemURI.js b/lib/playbook/plugin/playbook/resolveLocalFileSystemURI.js
new file mode 100644
index 0000000..e02cfc3
--- /dev/null
+++ b/lib/playbook/plugin/playbook/resolveLocalFileSystemURI.js
@@ -0,0 +1,55 @@
+var DirectoryEntry = require('cordova/plugin/DirectoryEntry'),
+ FileEntry = require('cordova/plugin/FileEntry'),
+ FileError = require('cordova/plugin/FileError');
+
+/**
+ * Look up file system Entry referred to by local URI.
+ * @param {DOMString} uri URI referring to a local file or directory
+ * @param successCallback invoked with Entry object corresponding to URI
+ * @param errorCallback invoked if error occurs retrieving file system entry
+ */
+module.exports = function(uri, successCallback, errorCallback) {
+ // error callback
+ var fail = function(error) {
+ if (typeof errorCallback === 'function') {
+ errorCallback(new FileError(error));
+ }
+ };
+ // if successful, return either a file or directory entry
+ var success = function(entry) {
+ var result;
+
+ if (entry) {
+ if (typeof successCallback === 'function') {
+ // create appropriate Entry object
+ result = (entry.isDirectory) ? new DirectoryEntry(entry.name, entry.fullPath) : new FileEntry(entry.name, entry.fullPath);
+ try {
+ successCallback(result);
+ }
+ catch (e) {
+ console.log('Error invoking callback: ' + e);
+ }
+ }
+ }
+ else {
+ // no Entry object returned
+ fail(FileError.NOT_FOUND_ERR);
+ }
+ };
+ var theEntry = {};
+
+ if(blackberry.io.dir.exists(uri)){
+ theEntry.isDirectory = true;
+ theEntry.name = uri.split('/').pop();
+ theEntry.fullPath = uri;
+ success(theEntry);
+ }else if(blackberry.io.file.exists(uri)){
+ theEntry.isDirectory = false;
+ theEntry.name = uri.split('/').pop();
+ theEntry.fullPath = uri;
+ success(theEntry);
+ }else{
+ // TODO: Throw error
+ }
+ //exec(success, fail, "File", "resolveLocalFileSystemURI", [uri]);
+};