if (NS_SUCCEEDED(rv)) { rv = (*aLocalFile)->Exists(&exists); if (NS_SUCCEEDED(rv) && !exists) { char path[_MAX_PATH]; PRInt32 len = GetWindowsDirectory( path, _MAX_PATH );   if (len <= _MAX_PATH-2) { path[len]   = '\\'; path[len+1] = '\0'; } rv = NS_NewLocalFile(path, PR_TRUE, aLocalFile); } }
static nsresult GetDefaultUserProfileRoot(nsILocalFile **aLocalFile){   nsresult rv;   PRBool exists;   nsILocalFile *pLocalFile;   #if defined(XP_MAC)    rv = GetMacFolder(kDocumentsFolderType, aLocalFile);    NS_ENSURE_SUCCESS(rv, rv);    pLocalFile = *aLocalFile;    pLocalFile->AppendRelativePath("Mozilla");    rv = pLocalFile->Exists(&exists);    NS_ENSURE_SUCCESS(rv, rv);    if (!exists) {      rv = pLocalFile->Create(nsIFile::DIRECTORY_TYPE, 0);      NS_ENSURE_SUCCESS(rv, rv);    }    pLocalFile->AppendRelativePath("Users50");    rv = pLocalFile->Exists(&exists);    NS_ENSURE_SUCCESS(rv, rv);    if (!exists) {      rv = pLocalFile->Create(nsIFile::DIRECTORY_TYPE, 0);      NS_ENSURE_SUCCESS(rv, rv);    }    #elif defined(XP_OS2)    PPIB ppib;    PTIB ptib;    char buffer[CCHMAXPATH];    DosGetInfoBlocks( &ptib, &ppib);    DosQueryModuleName( ppib->pib_hmte, CCHMAXPATH, buffer);    *strrchr( buffer, '\\') = '\0'; // OS2TODO DBCS misery    *strrchr( buffer, '\\') = '\0'; // OS2TODO DBCS misery    rv = NS_NewLocalFile(buffer, PR_TRUE, aLocalFile);    NS_ENSURE_SUCCESS(rv, rv);    pLocalFile = *aLocalFile;    pLocalFile->AppendRelativePath("Users50");    rv = pLocalFile->Exists(&exists);    NS_ENSURE_SUCCESS(rv, rv);    if (!exists) {      rv = pLocalFile->Create(nsIFile::DIRECTORY_TYPE, 0);      NS_ENSURE_SUCCESS(rv, rv);    }#elif defined(XP_PC)    rv = GetWindowsFolder(CSIDL_APPDATA, aLocalFile);    NS_ENSURE_SUCCESS(rv, rv);    pLocalFile = *aLocalFile;    pLocalFile->AppendRelativePath("Mozilla");    rv = pLocalFile->Exists(&exists);    NS_ENSURE_SUCCESS(rv, rv);    if (!exists) {      rv = pLocalFile->Create(nsIFile::DIRECTORY_TYPE, 0);      NS_ENSURE_SUCCESS(rv, rv);    }    pLocalFile->AppendRelativePath("Users50");    rv = pLocalFile->Exists(&exists);    NS_ENSURE_SUCCESS(rv, rv);    if (!exists) {      rv = pLocalFile->Create(nsIFile::DIRECTORY_TYPE, 0);      NS_ENSURE_SUCCESS(rv, rv);    }#elif defined(XP_UNIX)    rv = NS_NewLocalFile(PR_GetEnv("HOME"), PR_TRUE, aLocalFile);    NS_ENSURE_SUCCESS(rv, rv);    pLocalFile = *aLocalFile;    pLocalFile->AppendRelativePath(".mozilla");    rv = pLocalFile->Exists(&exists);    NS_ENSURE_SUCCESS(rv, rv);    if (!exists) {      rv = pLocalFile->Create(nsIFile::DIRECTORY_TYPE, 0775);      NS_ENSURE_SUCCESS(rv, rv);    }#elif defined(XP_BEOS)    char path[MAXPATHLEN];    find_directory(B_USER_SETTINGS_DIRECTORY, 0, 0, path, MAXPATHLEN);    // Need enough space to add the trailing backslash    int len = strlen(path);    if (len > MAXPATHLEN-2)        return NS_ERROR_FAILURE;    path[len]   = '/';    path[len+1] = '\0';    rv = NS_NewLocalFile(path, PR_TRUE, aLocalFile);    NS_ENSURE_SUCCESS(rv, rv);    pLocalFile = *aLocalFile;    pLocalFile->AppendRelativePath("mozilla");    rv = pLocalFile->Exists(&exists);    NS_ENSURE_SUCCESS(rv, rv);    if (!exists) {      rv = pLocalFile->Create(nsIFile::DIRECTORY_TYPE, 0);      NS_ENSURE_SUCCESS(rv, rv);    }#else#error dont_know_how_to_do_profiles_on_your_platform#endif   return rv; }