You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2012/02/23 18:53:19 UTC
[27/35] git commit: added getFile to DirectoryEntry
added getFile to DirectoryEntry
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/fc8c3893
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/fc8c3893
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/fc8c3893
Branch: refs/heads/ios
Commit: fc8c38937f8b76040ca556e15fa51a464124a98e
Parents: cfc4398
Author: Fil Maj <fi...@nitobi.com>
Authored: Thu Feb 16 15:05:14 2012 -0800
Committer: Fil Maj <fi...@nitobi.com>
Committed: Thu Feb 16 15:05:14 2012 -0800
----------------------------------------------------------------------
lib/plugin/DirectoryEntry.js | 17 +++++++++++++++++
lib/plugin/resolveLocalFileSystemURI.js | 10 +++++-----
2 files changed, 22 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/fc8c3893/lib/plugin/DirectoryEntry.js
----------------------------------------------------------------------
diff --git a/lib/plugin/DirectoryEntry.js b/lib/plugin/DirectoryEntry.js
index 01ffb7e..be011eb 100644
--- a/lib/plugin/DirectoryEntry.js
+++ b/lib/plugin/DirectoryEntry.js
@@ -47,4 +47,21 @@ DirectoryEntry.prototype.removeRecursively = function(successCallback, errorCall
exec(successCallback, errorCallback, "File", "removeRecursively", [this.fullPath]);
};
+/**
+ * Creates or looks up a file
+ *
+ * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a file
+ * @param {Flags} options to create or excluively create the file
+ * @param {Function} successCallback is called with the new entry
+ * @param {Function} errorCallback is called with a FileError
+ */
+DirectoryEntry.prototype.getFile = function(path, options, successCallback, errorCallback) {
+ var win = function(result) {
+ var FileEntry = require('cordova/plugin/FileEntry');
+ var entry = new FileEntry(result.name, result.fullPath);
+ successCallback(entry);
+ };
+ exec(win, errorCallback, "File", "getFile", [this.fullPath, path, options]);
+};
+
module.exports = DirectoryEntry;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/fc8c3893/lib/plugin/resolveLocalFileSystemURI.js
----------------------------------------------------------------------
diff --git a/lib/plugin/resolveLocalFileSystemURI.js b/lib/plugin/resolveLocalFileSystemURI.js
index 8ca4642..375d960 100644
--- a/lib/plugin/resolveLocalFileSystemURI.js
+++ b/lib/plugin/resolveLocalFileSystemURI.js
@@ -15,18 +15,18 @@ module.exports = function(uri, successCallback, errorCallback) {
};
// if successful, return either a file or directory entry
var success = function(entry) {
- var result;
+ var result;
if (entry) {
// create appropriate Entry object
- result = (entry.isDirectory) ? new DirectoryEntry(entry) : new FileEntry(entry);
+ result = (entry.isDirectory) ? new DirectoryEntry(entry) : new FileEntry(entry);
try {
successCallback(result);
}
catch (e) {
console.log('Error invoking callback: ' + e);
- }
- }
+ }
+ }
else {
// no Entry object returned
fail(FileError.NOT_FOUND_ERR);
@@ -34,4 +34,4 @@ module.exports = function(uri, successCallback, errorCallback) {
};
exec(success, fail, "File", "resolveLocalFileSystemURI", [uri]);
-};
+};