NS_NewLocalFile(compDirPath, getter_AddRefs(compDir));
NS_NewLocalFile(compDirPath, PR_TRUE, getter_AddRefs(compDir));
PR_PUBLIC_API(nsresult) XPI_Init(   #ifdef XP_MAC                                    const FSSpec&       aXPIStubDir,                                     const FSSpec&       aProgramDir,#else                                    const char*         aProgramDir,#endif                                    const char*         aLogName,                                    pfnXPIProgress      progressCB ){    nsresult              rv;    nsCOMPtr<nsIFileSpec> nsIfsDirectory;    nsFileSpec            nsfsDirectory;    nsFileSpec            nsfsRegFile;    //--------------------------------------------------------------------    // Initialize XPCOM and AutoRegister() its components    //--------------------------------------------------------------------#ifdef XP_MAC    nsLocalFile *binDir = new nsLocalFile;	if (binDir)	{        binDir->InitWithFSSpec(&aXPIStubDir);        rv = NS_InitXPCOM(&gServiceMgr, binDir);    }    else        return NS_ERROR_FAILURE;            // binDir is contaminated now.  Need compDir to pass to AutoRegister.    nsLocalFile *compDir = new nsLocalFile;    if (compDir)        compDir->InitWithFSSpec(&aXPIStubDir);    else        return NS_ERROR_FAILURE;	#elif defined(XP_PC)    char componentPath[MAX_PATH];    getcwd(componentPath, MAX_PATH);    nsCOMPtr<nsILocalFile> file;    NS_NewLocalFile(componentPath, getter_AddRefs(file));        rv = NS_InitXPCOM(&gServiceMgr, file); #elif defined(XP_UNIX)    nsCOMPtr<nsILocalFile> file;    NS_NewLocalFile(aProgramDir, getter_AddRefs(file));        rv = NS_InitXPCOM(&gServiceMgr, file);     char cwd[1024];    char compDirPath[1024];    memset(cwd, 0, 1024);    memset(compDirPath, 0, 1024);    getcwd(cwd, 1024);    sprintf(compDirPath, "%s/components", cwd);    nsCOMPtr<nsILocalFile> compDir;    NS_NewLocalFile(compDirPath, getter_AddRefs(compDir));#else    rv = NS_InitXPCOM(&gServiceMgr, NULL);#endif    if (!NS_SUCCEEDED(rv))        return rv;#if defined(XP_UNIX) || defined(XP_MAC)    rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup,                                           compDir);#else    rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup,                                           nsnull);#endif    if (!NS_SUCCEEDED(rv))        return rv;    //--------------------------------------------------------------------    // Get the SoftwareUpdate (XPInstall) service.    //    // Since AppShell is not started by XPIStub the XPI service is never     // registered with the service manager. We keep a local pointer to it     // so it stays alive througout.    //--------------------------------------------------------------------    rv = nsComponentManager::CreateInstance(kSoftwareUpdateCID,                                             nsnull,                                            NS_GET_IID(nsISoftwareUpdate),                                            (void**) &gXPI);    if (!NS_SUCCEEDED(rv))        return rv;    //--------------------------------------------------------------------    // Override XPInstall's natural assumption that the current executable    // is Mozilla. Use the given directory as the "Program" folder.    //--------------------------------------------------------------------    nsCOMPtr<nsPIXPIStubHook>   hook = do_QueryInterface(gXPI);    nsFileSpec                  dirSpec( aProgramDir );    nsCOMPtr<nsILocalFile>      iDirSpec;  #if XP_MAC	nsCOMPtr<nsILocalFileMac> iMacDirSpec;	NS_NewLocalFileWithFSSpec((FSSpec *)&aProgramDir, getter_AddRefs(iMacDirSpec));	iDirSpec = do_QueryInterface(iMacDirSpec);#else	NS_NewLocalFile(aProgramDir, getter_AddRefs(iDirSpec));#endif            if (hook && iDirSpec)    {        rv = hook->StubInitialize( iDirSpec, aLogName );        if (NS_FAILED(rv)) return rv;    }    else        return NS_ERROR_NULL_POINTER;    //--------------------------------------------------------------------    // Save the install wizard's callbacks as a nsIXPINotifer for later    //--------------------------------------------------------------------    nsStubListener* stub = new nsStubListener( progressCB );    if (!stub)    {        gXPI->Release();        rv = NS_ERROR_OUT_OF_MEMORY;    }    else    {        rv = stub->QueryInterface(NS_GET_IID(nsIXPIListener), (void**)&gListener);    }    return rv;}