Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Attributes
nsGREResProperties Class Reference

This class loads a .properties file from the gre/res directory; the file to load is specified as a constructor argument. More...

#include <nsGREResProperties.h>

Collaboration diagram for nsGREResProperties:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsGREResProperties (const nsACString &aFile)
PRBool DidLoad () const
 Returns whether loading the file succeeded.
nsresult Get (const nsAString &aKey, nsAString &value)

Private Attributes

nsCOMPtr< nsIPersistentPropertiesmProps

Detailed Description

This class loads a .properties file from the gre/res directory; the file to load is specified as a constructor argument.

Definition at line 49 of file nsGREResProperties.h.


Constructor & Destructor Documentation

Parameters:
aFileThe file to load. Must be an ASCII string.

Definition at line 44 of file nsGREResProperties.cpp.

{
  nsCOMPtr<nsIFile> file;
  nsresult rv = NS_GetSpecialDirectory(NS_GRE_DIR, getter_AddRefs(file));
  if (NS_FAILED(rv))
    return;

  file->AppendNative(NS_LITERAL_CSTRING("res"));
  file->AppendNative(aFile);

  nsCOMPtr<nsILocalFile> lf(do_QueryInterface(file));
  NS_ENSURE_TRUE(lf, );

  nsCOMPtr<nsIInputStream> inStr;
  rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), lf);
  if (NS_FAILED(rv))
    return;

  mProps = do_CreateInstance(NS_PERSISTENTPROPERTIES_CONTRACTID);
  if (mProps) {
    rv = mProps->Load(inStr);
    if (NS_FAILED(rv))
      mProps = nsnull;
  }
}

Here is the call graph for this function:


Member Function Documentation

Returns whether loading the file succeeded.

Definition at line 70 of file nsGREResProperties.cpp.

{
  return mProps != nsnull;
}
nsresult nsGREResProperties::Get ( const nsAString &  aKey,
nsAString &  value 
)

Definition at line 75 of file nsGREResProperties.cpp.

{
  if (!mProps)
    return NS_ERROR_NOT_INITIALIZED;

  return mProps->GetStringProperty(NS_ConvertUTF16toUTF8(aKey), aValue);
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 63 of file nsGREResProperties.h.


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