Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Protected Attributes
CAppFileLocationProvider Class Reference

#include <CAppFileLocationProvider.h>

Inheritance diagram for CAppFileLocationProvider:
Inheritance graph
Collaboration diagram for CAppFileLocationProvider:
Collaboration graph

List of all members.

Public Member Functions

 CAppFileLocationProvider (const nsAString &aAppDataDirName)
nsIFile getFile (in string prop, out PRBool persistent)

Protected Member Functions

virtual ~CAppFileLocationProvider ()
NS_METHOD GetAppDataDirectory (nsILocalFile **aLocalFile)

Protected Attributes

nsString mAppDataDirName

Detailed Description

Definition at line 50 of file CAppFileLocationProvider.h.

Constructor & Destructor Documentation

Definition at line 60 of file CAppFileLocationProvider.cpp.


Definition at line 65 of file CAppFileLocationProvider.cpp.


Member Function Documentation

Definition at line 125 of file CAppFileLocationProvider.cpp.

    nsresult rv;
    PRBool exists;
    nsCOMPtr<nsILocalFile> localDir;

    nsCOMPtr<nsIProperties> directoryService = 
             do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
    if (NS_FAILED(rv)) return rv;

    OSErr   err;
#if defined(XP_MACOSX)
    FSRef fsRef;
    err = ::FSFindFolder(kUserDomain, kApplicationSupportFolderType, kCreateFolder, &fsRef);
    if (err) return NS_ERROR_FAILURE;
    NS_NewLocalFile(EmptyString(), PR_TRUE, getter_AddRefs(localDir));
    if (!localDir) return NS_ERROR_FAILURE;
    nsCOMPtr<nsILocalFileMac> localDirMac(do_QueryInterface(localDir));
    rv = localDirMac->InitWithFSRef(&fsRef);
    if (NS_FAILED(rv)) return rv;
    long    response;
    err = ::Gestalt(gestaltSystemVersion, &response);
    const char *prop = (!err && response >= 0x00001000) ? NS_MAC_USER_LIB_DIR : NS_MAC_DOCUMENTS_DIR;
    rv = directoryService->Get(prop, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir));
    if (NS_FAILED(rv)) return rv;   

    rv = localDir->Append(mAppDataDirName);
    if (NS_FAILED(rv))
        return rv;
    rv = localDir->Exists(&exists);
    if (NS_SUCCEEDED(rv) && !exists)
        rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0775);
    if (NS_FAILED(rv))
        return rv;

    *aLocalFile = localDir;

    return rv; 

Here is the call graph for this function:

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 63 of file CAppFileLocationProvider.h.

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