Closed Bug 161912 Opened 22 years ago Closed 12 years ago

document nsIFile

Categories

(Core :: XPCOM, defect)

defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: timeless, Unassigned)

References

()

Details

Attachments

(1 file, 2 obsolete files)

it's @status FROZEN

and look at all of this wonderful documentation:
boolean nsIFile::exists (    )
boolean nsIFile::isWritable (    )
boolean nsIFile::isReadable (    )
boolean nsIFile::isExecutable (    )
boolean nsIFile::isHidden (    )
boolean nsIFile::isDirectory (    )
boolean nsIFile::isFile (    )
boolean nsIFile::isSymlink (    )

There's no indication if any of these methods will throw errors if files don't
exist or other fun things.

Some other gems:
boolean nsIFile::equals (  in nsIFile    inFile )
 Will determine if the inFile equals this. 

That's nice, but it didn't define what equals meant.

boolean nsIFile::contains (  in nsIFile    inFile, in boolean    recur) 
Will determine if inFile is a descendant of this file If |recur| is true, look
in subdirectories too.

I have no idea what this means.

 void nsIFile::createUnique  (   in unsigned long     type,
in unsigned long    permissions
) 
 

createUnique.

This function will create a new file or directory in the file system. Any nodes
that have not been created or resolved, will be. If this file already exists, we
try variations on the leaf name "suggestedName" until we find one that did not
already exist.

If the search for nonexistent files takes too long (thousands of the variants
already exist), we give up and return NS_ERROR_FILE_TOO_BIG.

"did not already exist" um, a file might have been created and deleted in which
case it already existed once.

"the search for /nonexistent/ file*s*" how many are you searching for? you only
need one right?

The idl docs talk about symlinks, aliases and shortcuts. but usually no more
than two at a time. It'd be nice if some sort of consistency was present. I'd
suggest always mentioning all three.

--
moveTo[Native].

This will move this file to the specified newParentDir. If a newName is
specified, the file will be renamed. If 'this' is not created we will return an
error (NS_ERROR_FILE_TARGET_DOES_NOT_EXIST).

*I'm willing to bet that the windows implementation violates this part of the
contract:*
moveTo will NOT resolve aliases/shortcuts during the copy.

/If the windows implementation doesn't violate the contract then it's probably
because the contract doesn't mention symlinks, in which case what you have is
totally useless./

moveTo will do the right thing and allow copies across volumes.
I agree with the bug, but not your sarcasm.  If you want to be helpful, try to
fix the problem and not just bitch about it!
Target Milestone: --- → Future
Attached patch lousy attempt at a patch (obsolete) — Splinter Review
Beware. This is my very first patch, so obviously it will suck. I did not
address most of timeless' comments, as I'm not familiar with nsIFile myself and
thus cannot answer all questions posed. This patch is incomplete and I only
upload it so I have an idea whether I'm doing the right thing.

In particular, I commented briefly on all "wonderfully documented" booleans and
reformulated some unclear expressions.

> There's no indication if any of these methods will throw errors

I don't know how to find this out.

> That's nice, but it didn't define what equals meant.

Ditto.

> Will determine if inFile is a descendant of this file If |recur| is true,
> look in subdirectories too.

As far as I can tell, a "descendant of a file" can only be a child of a
directory, so that's how I reformulated it. I may be wrong.

So, you can start flaming me now.
Comment on attachment 110310 [details] [diff] [review]
lousy attempt at a patch

Will write better version incorporating timeless' suggestions.
Attachment #110310 - Attachment is obsolete: true
Attached patch second take (obsolete) — Splinter Review
Comment on attachment 110316 [details] [diff] [review]
second take

your usage of e.g. seems wrong, you probably mean i.e., in all cases where you
added it.

the documentation for contains, the recur param, to be exact, has odd
indentation; please don't use tabs.

as for finding out if methods throw errors, if they have a |return NS_ERROR_*;|
somewhere, they do.

+     * Checks if the file is a directory.

uh, I'm sure this can be phrased better. s/file/nsIFile/ maybe.

+      *  clone()
Why are you mentioning the name of the function in the comment, you don't do it
for other functions either.
Attachment #110321 - Flags: review?(dougt)
taking
Assignee: dougt → bugzilla
ditto
Status: NEW → ASSIGNED
Comment on attachment 110321 [details] [diff] [review]
(Hopefully) addressed biesi's comments

You know most of these methods can return many more error codes than just what
you are listing.  For example, in Create() we map the error code with
ConvertWinError(GetLastError());

How do you plan to document these errors?
What about listing the errors that ConvertWinError (and other platforms'
equivalents) can return near the top of the idl file, with a comment like "These
errors are possibly returned from all of the member functions here"?
darin, you should try to intergrate as much of this as you can into your other
nsIFile bug.
I'm sorry, I don't have time to work on this any longer.
Assignee: bugzilla → nobody
Status: ASSIGNED → NEW
OS: Windows 2000 → All
QA Contact: scc → xpcom
Hardware: PC → All
Target Milestone: Future → ---
Comment on attachment 110321 [details] [diff] [review]
(Hopefully) addressed biesi's comments

clearing review flags.
Attachment #110321 - Flags: review?(dougt)
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: