Christian Biesinger <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]:
> On Mon, Jan 17, 2005 at 03:44:54PM +0000, Patient Guy wrote:
>> This was so because fname is the string ".", and apparently this is
>> not allowed, which seems odd, because if access is being granted to
>> the file system at any part of the hierarchy, how is accessing the
>> current directory a security problem?
>
> Passing relative paths to nsILocalFile.initWithPath is not supported.
Thanks for that.
I finally figured out what I wanted to do regarding this, which was to
use the DirectoryServiceProvider interface and a call to get a starting
path.
But now I have come across another problem (below).
>> QUESTION: How do I get the file object to be a directory that is set
>> to the current directory?
>
> Not sure if you can, but why do you want something that is often the
> installation directory of mozilla?
>
>> Error: uncaught exception: Permission denied to get property
>> UnnamedClass.directoryEntries
>
> Is this in the same function that called enablePrivilege? It has to
> be...
Good call again. No, it was in a different function. I am not entirely
sure how the enablePrivilege method works and what its scope is.
But now I have inserted it into the function, and it is returning the
property directoryEntries of the nsILocalFile object/component, which is
a nsISimpleEnumerator.
Heres is the code fragment:
function readdir(DirObj)
{
if (typeof(DirObj) == "undefined" || DirObj == null)
return (null);
var direntry, name, fitem; // directory entry object
if (/* this is an IE browser */)
{
....
}
else if (DirObj.dir.browser == "mz" || DirObj.dir.browser == "nn")
{
netscape.security.PrivilegeManager.
enablePrivilege("UniversalXPConnect");
if (DirObj.files == null)
DirObj.files = DirObj.dir.fileObject.directoryEntries;
if (DirObj.files.hasMoreElements() == false)
return (null);
fitem = DirObj.files.getNext();
// each item returned is an nsIFile
----> var fItemName = fitem.path.match(/.*[\/\\](\S+)/)[1];
return (new Dirent(fitemName, fitem, fItemName.length, null));
}
return (null);
}
All this code I am writing is to make neat UNIX-like filesystem calls to
wrap around browser-dependent filesystem interfaces.
The error is at the ---->. 'fItemName' has no 'path' property, which is
the cause of the error
Using Venkman, there are no properties at all, it has only one function:
QueryInterface(). Is this an nsISupports component? The references say
that on the enumerated items from directoryEntries, .getNext() is
supposed to return an nsIFile component/object.
_______________________________________________
Mozilla-xpcom mailing list
[email protected]
http://mail.mozilla.org/listinfo/mozilla-xpcom