You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2013/10/28 23:12:32 UTC

[4/5] git commit: CB-5129: Add a consistent filesystem attribute to FileEntry and DirectoryEntry objects

CB-5129: Add a consistent filesystem attribute to FileEntry and DirectoryEntry objects


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/commit/1c022459
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/1c022459
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/1c022459

Branch: refs/heads/master
Commit: 1c022459c6ac71a8b5bfb479b063278292a78e04
Parents: 5ff5b80
Author: Ian Clelland <ic...@chromium.org>
Authored: Tue Oct 22 14:45:37 2013 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Wed Oct 23 11:50:39 2013 -0400

----------------------------------------------------------------------
 www/DirectoryEntry.js | 12 +++++++-----
 www/Entry.js          | 10 +++++++---
 www/FileEntry.js      |  4 ++--
 www/FileSystem.js     |  2 +-
 4 files changed, 17 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/1c022459/www/DirectoryEntry.js
----------------------------------------------------------------------
diff --git a/www/DirectoryEntry.js b/www/DirectoryEntry.js
index 9e55adf..053ef9a 100644
--- a/www/DirectoryEntry.js
+++ b/www/DirectoryEntry.js
@@ -33,10 +33,10 @@ var argscheck = require('cordova/argscheck'),
  * {boolean} isDirectory always true (readonly)
  * {DOMString} name of the directory, excluding the path leading to it (readonly)
  * {DOMString} fullPath the absolute full path to the directory (readonly)
- * TODO: implement this!!! {FileSystem} filesystem on which the directory resides (readonly)
+ * {FileSystem} filesystem on which the directory resides (readonly)
  */
-var DirectoryEntry = function(name, fullPath) {
-     DirectoryEntry.__super__.constructor.call(this, false, true, name, fullPath);
+var DirectoryEntry = function(name, fullPath, fileSystem) {
+     DirectoryEntry.__super__.constructor.call(this, false, true, name, fullPath, fileSystem);
 };
 
 utils.extend(DirectoryEntry, Entry);
@@ -58,8 +58,9 @@ DirectoryEntry.prototype.createReader = function() {
  */
 DirectoryEntry.prototype.getDirectory = function(path, options, successCallback, errorCallback) {
     argscheck.checkArgs('sOFF', 'DirectoryEntry.getDirectory', arguments);
+    var fs = this.filesystem;
     var win = successCallback && function(result) {
-        var entry = new DirectoryEntry(result.name, result.fullPath);
+        var entry = new DirectoryEntry(result.name, result.fullPath, fs);
         successCallback(entry);
     };
     var fail = errorCallback && function(code) {
@@ -92,9 +93,10 @@ DirectoryEntry.prototype.removeRecursively = function(successCallback, errorCall
  */
 DirectoryEntry.prototype.getFile = function(path, options, successCallback, errorCallback) {
     argscheck.checkArgs('sOFF', 'DirectoryEntry.getFile', arguments);
+    var fs = this.filesystem;
     var win = successCallback && function(result) {
         var FileEntry = require('./FileEntry');
-        var entry = new FileEntry(result.name, result.fullPath);
+        var entry = new FileEntry(result.name, result.fullPath, fs);
         successCallback(entry);
     };
     var fail = errorCallback && function(code) {

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/1c022459/www/Entry.js
----------------------------------------------------------------------
diff --git a/www/Entry.js b/www/Entry.js
index 0e1bc02..09afb6f 100644
--- a/www/Entry.js
+++ b/www/Entry.js
@@ -37,6 +37,9 @@ var argscheck = require('cordova/argscheck'),
  * @param fullPath
  *            {DOMString} the absolute full path to the file or directory
  *            (readonly)
+ * @param fileSystem
+ *            {FileSystem} the filesystem on which this entry resides
+ *            (readonly)
  */
 function Entry(isFile, isDirectory, name, fullPath, fileSystem) {
     this.isFile = !!isFile;
@@ -107,7 +110,7 @@ Entry.prototype.moveTo = function(parent, newName, successCallback, errorCallbac
             if (entry) {
                 if (successCallback) {
                     // create appropriate Entry object
-                    var result = (entry.isDirectory) ? new (require('./DirectoryEntry'))(entry.name, entry.fullPath) : new (require('org.apache.cordova.file.FileEntry'))(entry.name, entry.fullPath);
+                    var result = (entry.isDirectory) ? new (require('./DirectoryEntry'))(entry.name, entry.fullPath, entry.filesystem) : new (require('org.apache.cordova.file.FileEntry'))(entry.name, entry.fullPath, entry.filesystem);
                     successCallback(result);
                 }
             }
@@ -148,7 +151,7 @@ Entry.prototype.copyTo = function(parent, newName, successCallback, errorCallbac
             if (entry) {
                 if (successCallback) {
                     // create appropriate Entry object
-                    var result = (entry.isDirectory) ? new (require('./DirectoryEntry'))(entry.name, entry.fullPath) : new (require('org.apache.cordova.file.FileEntry'))(entry.name, entry.fullPath);
+                    var result = (entry.isDirectory) ? new (require('./DirectoryEntry'))(entry.name, entry.fullPath, entry.filesystem) : new (require('org.apache.cordova.file.FileEntry'))(entry.name, entry.fullPath, entry.filesystem);
                     successCallback(result);
                 }
             }
@@ -206,9 +209,10 @@ Entry.prototype.remove = function(successCallback, errorCallback) {
  */
 Entry.prototype.getParent = function(successCallback, errorCallback) {
     argscheck.checkArgs('FF', 'Entry.getParent', arguments);
+    var fs = this.filesystem;
     var win = successCallback && function(result) {
         var DirectoryEntry = require('./DirectoryEntry');
-        var entry = new DirectoryEntry(result.name, result.fullPath);
+        var entry = new DirectoryEntry(result.name, result.fullPath, fs);
         successCallback(entry);
     };
     var fail = errorCallback && function(code) {

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/1c022459/www/FileEntry.js
----------------------------------------------------------------------
diff --git a/www/FileEntry.js b/www/FileEntry.js
index 79064ac..dc9352d 100644
--- a/www/FileEntry.js
+++ b/www/FileEntry.js
@@ -35,8 +35,8 @@ var utils = require('cordova/utils'),
  * {DOMString} fullPath the absolute full path to the file (readonly)
  * {FileSystem} filesystem on which the file resides (readonly)
  */
-var FileEntry = function(name, fullPath) {
-     FileEntry.__super__.constructor.apply(this, [true, false, name, fullPath]);
+var FileEntry = function(name, fullPath, fileSystem) {
+     FileEntry.__super__.constructor.apply(this, [true, false, name, fullPath, fileSystem]);
 };
 
 utils.extend(FileEntry, Entry);

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/1c022459/www/FileSystem.js
----------------------------------------------------------------------
diff --git a/www/FileSystem.js b/www/FileSystem.js
index 030365f..76e3f89 100644
--- a/www/FileSystem.js
+++ b/www/FileSystem.js
@@ -31,7 +31,7 @@ var DirectoryEntry = require('./DirectoryEntry');
 var FileSystem = function(name, root) {
     this.name = name || null;
     if (root) {
-        this.root = new DirectoryEntry(root.name, root.fullPath);
+        this.root = new DirectoryEntry(root.name, root.fullPath, this);
     }
 };