Added URL attribute to nsIFile (why: because (a) needs to vary for different implementations, and (b) need to factor out of necko for installer). Not implemented yet.
This commit is contained in:
@@ -2088,6 +2088,45 @@ nsLocalFile::GetDirectoryEntries(nsISimpleEnumerator * *entries)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsLocalFile::GetURL(char * *aURL)
|
||||
{
|
||||
nsresult rv;
|
||||
char* ePath = (char*) nsMemory::Clone(mWorkingPath, strlen(mWorkingPath)+1);
|
||||
if (ePath == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
// Replace \ with / to convert to an url
|
||||
char* s = ePath;
|
||||
while (*s) {
|
||||
if (*s == '\\')
|
||||
*s = '/';
|
||||
s++;
|
||||
}
|
||||
// Escape the path with the directory mask
|
||||
nsCAutoString tmp = ePath;
|
||||
tmp.ReplaceChar(":", '|');
|
||||
nsCAutoString escPath = "file://";
|
||||
escPath += tmp;
|
||||
// rv = nsURLEscape(ePath,nsIIOService::url_Directory + nsIIOService::url_Forced, escPath);
|
||||
// if (NS_SUCCEEDED(rv)) {
|
||||
PRBool dir;
|
||||
rv = IsDirectory(&dir);
|
||||
if (NS_SUCCEEDED(rv) && dir && escPath[escPath.Length() - 1] != '/') {
|
||||
// make sure we have a trailing slash
|
||||
escPath += "/";
|
||||
}
|
||||
*aURL = escPath.ToNewCString();
|
||||
if (*aURL == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
// }
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsLocalFile::SetURL(const char * aURL)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::GetPersistentDescriptor(char * *aPersistentDescriptor)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user