Closed
Bug 361351
Opened 18 years ago
Closed 18 years ago
nsIFile.exists() should throw NOT_INITIALIZED if nsIFile is not initialized
Categories
(Core :: XPCOM, defect)
Core
XPCOM
Tracking
()
RESOLVED
FIXED
mozilla1.9alpha1
People
(Reporter: paulie4, Assigned: sciguyryan)
Details
Attachments
(2 files, 2 obsolete files)
|
33.15 KB,
patch
|
darin.moz
:
review+
darin.moz
:
superreview+
|
Details | Diff | Splinter Review |
|
615 bytes,
patch
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0
nsIFile.exists() causes an error if nsIFile is not initialized, even though it just returns false in Windows. Returning false seems like the most reasonable thing to do. This makes programming cross platform extensions more tedious.
Reproducible: Always
Steps to Reproduce:
1.var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsIFile);
2.file.exists();
Actual Results:
NS_ERROR_NOT_INITIALIZED on line 1: Component returned failure code: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED) [nsIFile.exists]
(just false on Windows)
Expected Results:
false
Comment 1•18 years ago
|
||
I would assert that the behavior on linux is entirely correct. But I do agree that the same behavior should exist on all platforms.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Comment 2•18 years ago
|
||
Expected behavior should be to throw NOT_INITIALIZED on all platforms.
How does one check for initialization?
(nsIFile.nativePath != "") OR (nsIFile.path != "")?
Comment 4•18 years ago
|
||
OK, this bug exists on at least Win and OSX. Unix checks for initialization here:
http://lxr.mozilla.org/seamonkey/source/xpcom/io/nsLocalFileUnix.cpp#109
OS: Linux → All
Hardware: PC → All
Summary: nsIFile.exists() causes an error if nsIFile is not initialized → nsIFile.exists() should throw NOT_INITIALIZED if nsIFile is not initialized
| Assignee | ||
Comment 5•18 years ago
|
||
(In reply to comment #4)
> OK, this bug exists on at least Win and OSX. Unix checks for initialization
> here:
>
> http://lxr.mozilla.org/seamonkey/source/xpcom/io/nsLocalFileUnix.cpp#109
>
The same thing (or similar) can be done on Windows and Mac too then? I'll try and look at this tomorrow after school.
| Assignee | ||
Comment 6•18 years ago
|
||
* Attempt v1. Only patch for nsLocalFileWin.cpp - if this looks correct I'll make a similar patch for Mac and OS2 if its required.
Attachment #246490 -
Flags: review?(darin.moz)
Comment 7•18 years ago
|
||
Comment on attachment 246490 [details] [diff] [review]
Like this? (nsLocalFileWin v1)
Do all of the other platform ports behave the same? Is this something you could create a PASS/FAIL unit test for in mozilla/xpcom/tests?
Maybe extend nsIFileTest.cpp or create a new test that mimics how TestTArray.cpp and TestStrings.cpp are written.
Attachment #246490 -
Flags: review?(darin.moz) → review+
| Assignee | ||
Updated•18 years ago
|
Assignee: nobody → sciguyryan+bugzilla
| Assignee | ||
Comment 8•18 years ago
|
||
It looks like Mac already does this:
http://lxr.mozilla.org/mozilla/source/xpcom/io/nsLocalFileOSX.cpp#417
For example. OS2 does appear to be affected and I will submit a patch shortly.
| Assignee | ||
Comment 9•18 years ago
|
||
* Patch v1 for nsLocalFileOS2.
Attachment #246816 -
Flags: superreview?(darin.moz)
Attachment #246816 -
Flags: review?(darin.moz)
| Assignee | ||
Updated•18 years ago
|
Attachment #246490 -
Flags: superreview?(darin.moz)
| Assignee | ||
Comment 10•18 years ago
|
||
I've checked Mac and Unix and they seem to be covered in this case.(In reply to comment #7)
> (From update of attachment 246490 [details] [diff] [review] [edit])
> Do all of the other platform ports behave the same? Is this something you
> could create a PASS/FAIL unit test for in mozilla/xpcom/tests?
>
> Maybe extend nsIFileTest.cpp or create a new test that mimics how
> TestTArray.cpp and TestStrings.cpp are written.
>
Would a test be needed in this case? If so I'll try and create one.
Comment 11•18 years ago
|
||
> It looks like Mac already does this:
not for exists():
http://lxr.mozilla.org/mozilla/source/xpcom/io/nsLocalFileOSX.cpp#915
| Assignee | ||
Updated•18 years ago
|
Attachment #246490 -
Flags: superreview?(darin.moz)
| Assignee | ||
Updated•18 years ago
|
Attachment #246816 -
Flags: superreview?(darin.moz)
Attachment #246816 -
Flags: review?(darin.moz)
| Assignee | ||
Comment 12•18 years ago
|
||
* Merged patch v1.
This is a merged patch containing the changes too nsLocalFileOSX, nsLocalFileWin and nsLocalFileOS2.
If there are any other functions that require initialization checking let me know and I will make a new patch as required.
Attachment #246832 -
Flags: superreview?(darin.moz)
Attachment #246832 -
Flags: review?(darin.moz)
Updated•18 years ago
|
Attachment #246832 -
Flags: superreview?(darin.moz)
Attachment #246832 -
Flags: superreview+
Attachment #246832 -
Flags: review?(darin.moz)
Attachment #246832 -
Flags: review+
| Assignee | ||
Comment 13•18 years ago
|
||
I'll get working on a test for this as soon as I get a little free time (hopefully this week).
Status: NEW → ASSIGNED
Whiteboard: [checkin needed]
Comment 14•18 years ago
|
||
mozilla/xpcom/io/nsLocalFileOS2.cpp 1.93
mozilla/xpcom/io/nsLocalFileOSX.cpp 1.45
mozilla/xpcom/io/nsLocalFileWin.cpp 1.168
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Whiteboard: [checkin needed]
Target Milestone: --- → mozilla1.9alpha
Comment 15•18 years ago
|
||
Attachment #246490 -
Attachment is obsolete: true
Attachment #246816 -
Attachment is obsolete: true
You need to log in
before you can comment on or make changes to this bug.
Description
•