mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-23 18:26:15 +00:00
Bug 840887 - DirectoryIterator.prototype.exists - asynchronous version. r=froydnj
This commit is contained in:
parent
f28096d843
commit
15b21c14a2
@ -627,6 +627,18 @@ let DirectoryIterator = function DirectoryIterator(path, options) {
|
|||||||
this._isClosed = false;
|
this._isClosed = false;
|
||||||
};
|
};
|
||||||
DirectoryIterator.prototype = {
|
DirectoryIterator.prototype = {
|
||||||
|
/**
|
||||||
|
* Determine whether the directory exists.
|
||||||
|
*
|
||||||
|
* @resolves {boolean}
|
||||||
|
*/
|
||||||
|
exists: function exists() {
|
||||||
|
return this._itmsg.then(
|
||||||
|
function onSuccess(iterator) {
|
||||||
|
return Scheduler.post("DirectoryIterator_prototype_exists", [iterator]);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Get the next entry in the directory.
|
* Get the next entry in the directory.
|
||||||
*
|
*
|
||||||
@ -728,7 +740,6 @@ DirectoryIterator.prototype = {
|
|||||||
*/
|
*/
|
||||||
_next: function _next(iterator) {
|
_next: function _next(iterator) {
|
||||||
if (this._isClosed) {
|
if (this._isClosed) {
|
||||||
LOG("DirectoryIterator._next", "closed");
|
|
||||||
return this._itmsg;
|
return this._itmsg;
|
||||||
}
|
}
|
||||||
let self = this;
|
let self = this;
|
||||||
|
@ -356,6 +356,12 @@ if (this.Components) {
|
|||||||
this.close();
|
this.close();
|
||||||
OpenedDirectoryIterators.remove(dir);
|
OpenedDirectoryIterators.remove(dir);
|
||||||
}, true);// ignore error to support double-closing |DirectoryIterator|
|
}, true);// ignore error to support double-closing |DirectoryIterator|
|
||||||
|
},
|
||||||
|
DirectoryIterator_prototype_exists: function exists(dir) {
|
||||||
|
return withDir(dir,
|
||||||
|
function do_exists() {
|
||||||
|
return this.exists();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} catch(ex) {
|
} catch(ex) {
|
||||||
|
Loading…
Reference in New Issue
Block a user