NS_INIT_ISUPPORTS();
SimpleDirectoryProvider::SimpleDirectoryProvider(){    NS_INIT_ISUPPORTS();    nsCOMPtr<nsILocalFile> appDataDir;    // Attempt to fill appDataDir with a meaningful value. Any error in the process    // will cause the constructor to return and IsValid() to return FALSE,    CComPtr<IMalloc> shellMalloc;    SHGetMalloc(&shellMalloc);    if (shellMalloc)    {        LPITEMIDLIST pitemidList = NULL;        SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pitemidList);        if (pitemidList)        {            TCHAR szBuffer[MAX_PATH + 1];            if (SUCCEEDED(SHGetPathFromIDList(pitemidList, szBuffer)))            {                szBuffer[MAX_PATH] = TCHAR('\0');                USES_CONVERSION;                NS_NewNativeLocalFile(nsDependentCString(T2A(szBuffer)), TRUE, getter_AddRefs(appDataDir));            }            shellMalloc->Free(pitemidList);        }    }    if (!appDataDir)    {        return;    }    // Mozilla control paths are    // App data     - {Application Data}/MozillaControl    // App registry - {Application Data}/MozillaControl/registry.dat    // Profiles     - {Application Data}/MozillaControl/profiles    nsresult rv;    // Create the root directory    PRBool exists;    rv = appDataDir->Exists(&exists);    if (NS_FAILED(rv) || !exists) return;    // MozillaControl application data    rv = appDataDir->AppendRelativePath(NS_LITERAL_STRING("MozillaControl"));    if (NS_FAILED(rv)) return;    rv = appDataDir->Exists(&exists);    if (NS_SUCCEEDED(rv) && !exists)        rv = appDataDir->Create(nsIFile::DIRECTORY_TYPE, 0775);    if (NS_FAILED(rv)) return;    // Registry.dat file    nsCOMPtr<nsIFile> appDataRegAsFile;    rv = appDataDir->Clone(getter_AddRefs(appDataRegAsFile));    if (NS_FAILED(rv)) return;    nsCOMPtr<nsILocalFile> appDataRegistry = do_QueryInterface(appDataRegAsFile, &rv);    if (NS_FAILED(rv)) return;    appDataRegistry->AppendRelativePath(NS_LITERAL_STRING("registry.dat"));    // Profiles directory    nsCOMPtr<nsIFile> profileDirAsFile;    rv = appDataDir->Clone(getter_AddRefs(profileDirAsFile));    if (NS_FAILED(rv)) return;    nsCOMPtr<nsILocalFile> profileDir = do_QueryInterface(profileDirAsFile, &rv);    if (NS_FAILED(rv)) return;    profileDir->AppendRelativePath(NS_LITERAL_STRING("profiles"));    rv = profileDir->Exists(&exists);    if (NS_SUCCEEDED(rv) && !exists)        rv = profileDir->Create(nsIFile::DIRECTORY_TYPE, 0775);    if (NS_FAILED(rv)) return;    // Store the member values    mApplicationRegistryDir = appDataDir;    mApplicationRegistryFile = appDataRegistry;    mUserProfileDir = profileDir;}