Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Protected Attributes
SimpleDirectoryProvider Class Reference
Inheritance diagram for SimpleDirectoryProvider:
Inheritance graph
Collaboration diagram for SimpleDirectoryProvider:
Collaboration graph

List of all members.

Public Member Functions

 SimpleDirectoryProvider ()
BOOL IsValid () const
nsIFile getFile (in string prop, out PRBool persistent)

Protected Member Functions

virtual ~SimpleDirectoryProvider ()

Protected Attributes

nsCOMPtr< nsILocalFilemApplicationRegistryDir
nsCOMPtr< nsILocalFilemApplicationRegistryFile
nsCOMPtr< nsILocalFilemUserProfileDir

Detailed Description

Definition at line 105 of file MozillaBrowser.cpp.

Constructor & Destructor Documentation

Definition at line 1928 of file MozillaBrowser.cpp.

    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;
    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');
                NS_NewNativeLocalFile(nsDependentCString(T2A(szBuffer)), TRUE, getter_AddRefs(appDataDir));
    if (!appDataDir)

    // 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;

    // 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;
    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;

Here is the call graph for this function:

Definition at line 2004 of file MozillaBrowser.cpp.


Member Function Documentation

nsIFile nsIDirectoryServiceProvider::getFile ( in string  prop,
out PRBool  persistent 
) [inherited]


Directory Service calls this when it gets the first request for a prop or on every request if the prop is not persistent.

propThe symbolic name of the file.
persistentTRUE - The returned file will be cached by Directory Service. Subsequent requests for this prop will bypass the provider and use the cache. FALSE - The provider will be asked for this prop each time it is requested.
The file represented by the property.

Member Data Documentation

Definition at line 119 of file MozillaBrowser.cpp.

Definition at line 120 of file MozillaBrowser.cpp.

Definition at line 121 of file MozillaBrowser.cpp.

The documentation for this class was generated from the following file: