modules/libpref/public/nsIRelativeFilePref.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/modules/libpref/public/nsIRelativeFilePref.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,69 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "nsISupports.idl"
    1.10 +interface nsIFile;
    1.11 +
    1.12 +/**
    1.13 + * The nsIRelativeFilePref interface is a wrapper for an nsIFile and
    1.14 + * and a directory service key. When used as a pref value, it stores a
    1.15 + * relative path to the file from the location pointed to by the directory
    1.16 + * service key. The path has the same syntax across all platforms.
    1.17 + *
    1.18 + * @see nsIPrefBranch::getComplexValue
    1.19 + * @see nsIPrefBranch::setComplexValue
    1.20 + * 
    1.21 + */
    1.22 +
    1.23 +[scriptable, uuid(2f977d4e-5485-11d4-87e2-0010a4e75ef2)]
    1.24 +interface nsIRelativeFilePref : nsISupports
    1.25 +{
    1.26 +  /**
    1.27 +   * file
    1.28 +   *
    1.29 +   * The file whose location is stored or retrieved.
    1.30 +   */
    1.31 +  attribute nsIFile file;
    1.32 +
    1.33 +  /**
    1.34 +   * relativeToKey
    1.35 +   *
    1.36 +   * A directory service key for the directory
    1.37 +   * from which the file path is relative.
    1.38 +   */
    1.39 +  attribute ACString relativeToKey;
    1.40 +
    1.41 +};
    1.42 +
    1.43 +%{C++
    1.44 +
    1.45 +#define NS_RELATIVEFILEPREF_CID                        \
    1.46 +  { /* {2f977d4f-5485-11d4-87e2-0010a4e75ef2} */       \
    1.47 +    0x2f977d4f,                                        \
    1.48 +    0x5485,                                            \
    1.49 +    0x11d4,                                            \
    1.50 +    { 0x87, 0xe2, 0x00, 0x10, 0xa4, 0xe7, 0x5e, 0xf2 } \
    1.51 +  }
    1.52 +
    1.53 +#define NS_RELATIVEFILEPREF_CONTRACTID "@mozilla.org/pref-relativefile;1"
    1.54 +
    1.55 +#include "nsComponentManagerUtils.h"
    1.56 +
    1.57 +inline nsresult
    1.58 +NS_NewRelativeFilePref(nsIFile* aFile, const nsACString& relativeToKey, nsIRelativeFilePref** result)
    1.59 +{
    1.60 +    nsresult rv;
    1.61 +    nsCOMPtr<nsIRelativeFilePref> local(do_CreateInstance(NS_RELATIVEFILEPREF_CONTRACTID, &rv));
    1.62 +    if (NS_FAILED(rv)) return rv;
    1.63 +    
    1.64 +    (void)local->SetFile(aFile);
    1.65 +    (void)local->SetRelativeToKey(relativeToKey);
    1.66 +
    1.67 +    *result = local;
    1.68 +    NS_ADDREF(*result);
    1.69 +    return NS_OK;
    1.70 +}
    1.71 +
    1.72 +%}

mercurial