Closed
Bug 121489
Opened 23 years ago
Closed 22 years ago
nsIFile does not return null when top of volume is reached
Categories
(Core :: Networking: File, defect)
Core
Networking: File
Tracking
()
RESOLVED
FIXED
mozilla1.0
People
(Reporter: bzbarsky, Assigned: pete)
References
Details
Attachments
(1 file)
(deleted),
patch
|
dougt
:
review+
bzbarsky
:
superreview+
brendan
:
approval+
|
Details | Diff | Splinter Review |
286 /**
287 * Parent will be null when this is at the top of the volume.
288 */
289 readonly attribute nsIFile parent;
Looking at nsLocalFileUnix and nsLocalFileWin, that's not true in those impls.
In particular, the parent of "/" on unix is "/". Not sure what the parent is on
Win, exactly. Could we fix the comment or the impls, please? I just got into
an infinite loop because of this (was walking up the dir tree, and assumed that
I would hit null when I hit the top).
Reporter | ||
Comment 1•23 years ago
|
||
oops. wrong component. Sorry for the spam...
Assignee: law → dougt
Component: File Handling → Networking: File
QA Contact: sairuh → benc
Comment 2•23 years ago
|
||
Yeah, the implementions has the bug. We wanted a way to know when you reached
the top of the volume. Pete got any time to hit this?
Summary: nsIFile comments for .parent are wrong → nsIFile does not return null when top of volume is reached
Assignee | ||
Comment 3•23 years ago
|
||
I'll take it.
I just ordered parts to build myself a windows box. Akk!
So soon i will be able to work on the windows nsIFIle bugs.
--pete
Assignee: dougt → petejc
Assignee | ||
Updated•23 years ago
|
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla0.9.9
Assignee | ||
Updated•23 years ago
|
Target Milestone: mozilla0.9.9 → mozilla1.0
Pete: Is there any kind of external testcase that could be run for this bug?
Assignee | ||
Comment 5•22 years ago
|
||
Sure try this:
js> var f =
Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);
js> f;
[xpconnect wrapped nsILocalFile @ 0x80b2a50]
js> f.initWithPath('/');
js> f.parent;
[xpconnect wrapped nsIFile @ 0x80adea8]
js> f.parent.path;
/
js>
Parent of '/' should be null. This is an easy one to fix on unix.
--pete
On Unix and similar filesystems, the "parent" of / is /:
: osc; cd /
: /; cd ..
: /; pwd
/
Do we have good reason for not preserving that behaviour?
Assignee | ||
Comment 7•22 years ago
|
||
I agree w/ shaver. Parent of '/' is '/'. Seems correct to me.
> I just got into an infinite loop because of this
Seems client logic is wrong. Wouldn't you just use Equals() in this case to
determine when your parent nsIFile reached the top of the volume?
Comments bz?
--pete
Reporter | ||
Comment 8•22 years ago
|
||
> Seems client logic is wrong. Wouldn't you just use Equals()
No, because that would only work on Unix. On Windows/Mac it would not. So you
have to check both in the current world. _Further_, nsIFile.idl (which is
frozen, I must add) has, as I point out in comment 0:
304 /**
305 * Parent will be null when this is at the top of the volume.
306 */
307 readonly attribute nsIFile parent;
which is why my code was written the way it was when I ran into the infinite
loop. Please don't blame client logic that is based on the documentation in the
interface.
Now you can expect people to figure out for themselves that the Unix
implementation does not actually work the way the interface says it should
work.... or the two could agree. Or something.
Assignee | ||
Comment 9•22 years ago
|
||
Ah, lets blame dougt then. ;-)
Well, like i said, implementing it to work this way on unix shouldn't be a big deal.
--pete
Comment 10•22 years ago
|
||
We want XP semantics. Null termination of the ancestor line among *objects*
linked by *pointers* is cleanest for XPCOM nsIFile (Unix i-numbers don't have an
obvious "null" value, so /.. => / made more sense as a terminator to ken and
dmr, I suppose). Nuff said.
/be
Assignee | ||
Comment 12•22 years ago
|
||
Assignee | ||
Comment 13•22 years ago
|
||
js> f;
[xpconnect wrapped nsILocalFile @ 0x810d900]
js> f.initWithPath('/');
js> f.parent;
null
js>
Assignee | ||
Comment 14•22 years ago
|
||
Doug can you review this bro?
Thanks
--pete
Comment 15•22 years ago
|
||
Comment on attachment 98233 [details] [diff] [review]
fix
r=dougt. Lets get this into 1.2a.
Attachment #98233 -
Flags: review+
Reporter | ||
Comment 16•22 years ago
|
||
Comment on attachment 98233 [details] [diff] [review]
fix
sr=bzbarsky
Attachment #98233 -
Flags: superreview+
Assignee | ||
Comment 17•22 years ago
|
||
Checked in. Thanks for the speedy review guys.
--pete
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Comment 18•22 years ago
|
||
No harm done this time, but you should read the tinderbox rules before checking
in. This patch needed a= from a driver@mozilla.org. I can do that posthumously
(so to speak).
/be
Blocks: 1.2a
Updated•22 years ago
|
Attachment #98233 -
Flags: approval+
Assignee | ||
Comment 19•22 years ago
|
||
Shoot, i think i needed a=.
Sorry.I can pull it back if need be.
I just realized this an got mid air collision.
I'm rusty Brendan. ;-)
--pete
Comment 20•22 years ago
|
||
Is this still fixed? I was going to fix bug 129054 on my macho build and it
doesn't exhibit the problem (it doesn't return null for parent).
Blocks: 129054
Assignee | ||
Comment 21•22 years ago
|
||
Cathy, I don't have a trunk build handy but it still works using 1.3 RELEASE.
js> f.path;
/
js> f.parent;
null
js>
You need to log in
before you can comment on or make changes to this bug.
Description
•