CB-5129: Add a consistent filesystem attribute to FileEntry and DirectoryEntry objects
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 @@
* {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.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.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) {
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 @@
* @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 @@
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 @@
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.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) {
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 @@
* {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);
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 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);
}
};