Back to index

lightning-sunbird  0.9+nobinonly
Functions
nsRegisterItem.cpp File Reference
#include "prprf.h"
#include "nsRegisterItem.h"
#include "nsInstallResources.h"
#include "nsNetUtil.h"
#include "nsXPIDLString.h"
#include "nsReadableUtils.h"
#include "nsInstallTrigger.h"
#include "nsIChromeRegistry.h"
#include "nsIDirectoryService.h"
#include "nsDirectoryServiceDefs.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsNativeCharsetUtils.h"

Go to the source code of this file.

Functions

static nsresult hack_nsIFile2URL (nsIFile *file, char **aURL)

Function Documentation

static nsresult hack_nsIFile2URL ( nsIFile file,
char **  aURL 
) [static]

Definition at line 90 of file nsRegisterItem.cpp.

{
    nsresult rv;
    nsCAutoString ePath;
    rv = file->GetNativePath(ePath);
    if (NS_FAILED(rv)) return rv;
#if defined(XP_WIN) || defined(XP_OS2)
    // Replace \ with / to convert to an url
    char* s;
    ePath.BeginWriting(s);
    while (*s) {
#ifndef XP_OS2
        // We need to call IsDBCSLeadByte because
        // Japanese windows can have 0x5C in the sencond byte 
        // of a Japanese character, for example 0x8F 0x5C is
        // one Japanese character
        if(::IsDBCSLeadByte(*s) && *(s+1) != nsnull) {
            s++;
        } else 
#endif
            if (*s == '\\')
                *s = '/';
        s++;
    }
#endif
#if defined( XP_MAC )
    // Swap the / and colons to convert to an url
    SwapSlashColon(ePath.BeginWriting());
#endif
    // Escape the path with the directory mask
    nsCAutoString tmp(ePath);
    tmp.ReplaceChar(":", '|');
#ifdef XP_MAC
    nsCAutoString escPath("file:///");
#else
    nsCAutoString escPath("file://");
#endif
       escPath += tmp;
//    rv = nsURLEscape(ePath,nsIIOService::url_Directory + nsIIOService::url_Forced, escPath);
//    if (NS_SUCCEEDED(rv)) {
        PRBool dir;
        rv = file->IsDirectory(&dir);
        if (NS_SUCCEEDED(rv) && dir && escPath[escPath.Length() - 1] != '/') {
            // make sure we have a trailing slash
            escPath += "/";
        }
        *aURL = ToNewCString(escPath);
        if (*aURL == nsnull) {
            return NS_ERROR_OUT_OF_MEMORY;
        }
//    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function: