Doug Turner wrote:

> > In working with the xp filepicker, I've run into the problem of having to find out
> > whether a user typed in an absolute path or a relative path, and then call the 
>right
> > method (initWithPath / appendRelativePath) on nsILocalFile. This works "okay"
> > because right now the xp filepicker is only used on linux/unix, but it's still ugly
> > having to check if the typed in path starts with a "/" or not. This will become 
>even
> > uglier when you try to do this for other platforms like Windows, and imo doesn't
> > belong here, but "behind the scenes" in the implementation of nsILocalFile.
> >
> > I might however be missing the obvious, so I'm wondering, is there already a method
> > which allows me to get a nsILocalFile for an arbitrary path (as if I typed "more
> > <path>", where path can be "/foo/bar" or "baz" on linux, "c:\foo\bar" or "baz" on
> > Windows, etc.)?
>
> So your requesting that we have a method that will take an arbitrary path.  If it is 
>an
> absolute path, this method will init the nsIFile with this new location and if it is 
>a
> relative path, it will just append.  Is this a correct understanding?

Yes, and no. Depends on what you mean with "append". "Append" to me doesn't include
resolving a path like "~/foo/bar/" or "../../foo/baz"... Basically what I'm suggesting 
is
that you hand the OS[0] a path (whatever's currently in the nsIFile) and the path to be
resolved and ask it to tell you the result (which would be an absolute path). Based on 
the
result you would init the nsIFile, I guess.

  jag

[0] or otherwise do a damn good job of mimicking each OS' peculiarities ;-)


Reply via email to