Closed
Bug 840887
Opened 11 years ago
Closed 11 years ago
[OS.File] DirectoryIterator should fail consistently across platforms if the directory doesn't exist
Categories
(Toolkit Graveyard :: OS.File, defect)
Toolkit Graveyard
OS.File
Tracking
(Not tracked)
RESOLVED
FIXED
mozilla22
People
(Reporter: Yoric, Assigned: Yoric)
References
Details
(Keywords: dev-doc-needed)
Attachments
(5 files, 9 obsolete files)
767 bytes,
patch
|
Yoric
:
review+
|
Details | Diff | Splinter Review |
3.97 KB,
patch
|
Yoric
:
review+
|
Details | Diff | Splinter Review |
7.95 KB,
patch
|
Yoric
:
review+
|
Details | Diff | Splinter Review |
2.75 KB,
patch
|
Yoric
:
review+
|
Details | Diff | Splinter Review |
4.99 KB,
patch
|
Yoric
:
review+
|
Details | Diff | Splinter Review |
At the moment, attempting to iterate across a non-existing directory: - fails during |new DirectoryIterator(...)| under Unix; - fails during the first iteration under Windows. This is not very convenient for applications that need to iterate through a directory only if the directory exists. We should probably improve this.
Assignee | ||
Comment 1•11 years ago
|
||
Assignee: nobody → dteller
Assignee | ||
Comment 2•11 years ago
|
||
Comment on attachment 713858 [details] [diff] [review] DirectoryIterator should fail consistently across platforms I have made the following changes: - in synchronous mode, DirectoryIterator now consistently throws if the directory doesn't exist; - in asynchronous mode, a new method DirectoryIterator.prototype.exists lets users determine whether the directory effectively exists, without having to wait for an exception to be thrown during iteration. Nathan, what do you think of this?
Attachment #713858 -
Flags: feedback?(nfroyd)
Assignee | ||
Comment 3•11 years ago
|
||
Attaching a more robust implementation.
Attachment #713858 -
Attachment is obsolete: true
Attachment #713858 -
Flags: feedback?(nfroyd)
Attachment #714571 -
Flags: review?(nfroyd)
Assignee | ||
Comment 4•11 years ago
|
||
Attachment #714572 -
Flags: review?(nfroyd)
Assignee | ||
Comment 5•11 years ago
|
||
Attachment #714573 -
Flags: review?(nfroyd)
Assignee | ||
Comment 6•11 years ago
|
||
Attachment #714574 -
Flags: review?(nfroyd)
Assignee | ||
Comment 7•11 years ago
|
||
Attachment #714575 -
Flags: review?(khuey)
Assignee | ||
Comment 8•11 years ago
|
||
After more thought, I have decided that the best behavior is the following: - creating a DirectoryIterator for a non-existing directory is perfectly legal (makes it simpler to match semantics of synchronous and asynchronous implementations); - on the other hand, actually iterating through a non-existing directory throws an exception; - a method |exists| returns a boolean for the same purpose, without having to actually iterate through the directory.
Comment 9•11 years ago
|
||
Comment on attachment 714571 [details] [diff] [review] 1. Testing the behavior Review of attachment 714571 [details] [diff] [review]: ----------------------------------------------------------------- This looks sane enough, but you really want to put this patch last in the series or it may cause problems for bisecting.
Attachment #714571 -
Flags: review?(nfroyd) → review+
Updated•11 years ago
|
Attachment #714572 -
Flags: review?(nfroyd) → review+
Comment 10•11 years ago
|
||
Comment on attachment 714573 [details] [diff] [review] 3. Unix implementation Review of attachment 714573 [details] [diff] [review]: ----------------------------------------------------------------- ::: toolkit/components/osfile/osfile_unix_allthreads.jsm @@ +316,5 @@ > OSError.exists = function exists(operation) { > return new OSError(operation, OS.Constants.libc.EEXIST); > }; > + > + OSError.noSuchFile = function exists(operation) { |function noSuchFile|, I think.
Attachment #714573 -
Flags: review?(nfroyd) → review+
Comment 11•11 years ago
|
||
Comment on attachment 714574 [details] [diff] [review] 4. Windows implementation Review of attachment 714574 [details] [diff] [review]: ----------------------------------------------------------------- ::: toolkit/components/osfile/osfile_win_allthreads.jsm @@ +338,5 @@ > OSError.exists = function exists(operation) { > return new OSError(operation, exports.OS.Constants.Win.ERROR_FILE_EXISTS); > }; > + > + OSError.noSuchFile = function exists(operation) { |function noSuchFile|, I think.
Attachment #714574 -
Flags: review?(nfroyd) → review+
Assignee | ||
Comment 12•11 years ago
|
||
Changing the order of patches, plus adding a few tests.
Attachment #714571 -
Attachment is obsolete: true
Attachment #715925 -
Flags: review+
Assignee | ||
Comment 13•11 years ago
|
||
Attachment #714573 -
Attachment is obsolete: true
Attachment #715936 -
Flags: review+
Assignee | ||
Comment 14•11 years ago
|
||
Attachment #714574 -
Attachment is obsolete: true
Attachment #715937 -
Flags: review+
Attachment #714575 -
Flags: review?(khuey) → review+
Assignee | ||
Comment 15•11 years ago
|
||
Attachment #714575 -
Attachment is obsolete: true
Attachment #718429 -
Flags: review+
Assignee | ||
Comment 16•11 years ago
|
||
Attachment #715936 -
Attachment is obsolete: true
Attachment #718430 -
Flags: review+
Assignee | ||
Comment 17•11 years ago
|
||
Attachment #715937 -
Attachment is obsolete: true
Attachment #718437 -
Flags: review+
Assignee | ||
Comment 18•11 years ago
|
||
Attachment #714572 -
Attachment is obsolete: true
Attachment #718439 -
Flags: review+
Assignee | ||
Comment 19•11 years ago
|
||
Reordered patches prior to landing.
Attachment #715925 -
Attachment is obsolete: true
Attachment #718443 -
Flags: review+
Assignee | ||
Updated•11 years ago
|
Keywords: checkin-needed,
dev-doc-needed
Comment 20•11 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/7c638eba3a46 https://hg.mozilla.org/integration/mozilla-inbound/rev/bd4206b887ff https://hg.mozilla.org/integration/mozilla-inbound/rev/692f9ca21745 https://hg.mozilla.org/integration/mozilla-inbound/rev/65108c196870 https://hg.mozilla.org/integration/mozilla-inbound/rev/cf2f3b45cb38
Flags: in-testsuite+
Keywords: checkin-needed
Comment 21•11 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/7c638eba3a46 https://hg.mozilla.org/mozilla-central/rev/bd4206b887ff https://hg.mozilla.org/mozilla-central/rev/692f9ca21745 https://hg.mozilla.org/mozilla-central/rev/65108c196870 https://hg.mozilla.org/mozilla-central/rev/cf2f3b45cb38
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla22
Updated•11 months ago
|
Product: Toolkit → Toolkit Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•