Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "nsISupports.idl" |
michael@0 | 7 | interface nsIFile; |
michael@0 | 8 | |
michael@0 | 9 | /** |
michael@0 | 10 | * The nsIRelativeFilePref interface is a wrapper for an nsIFile and |
michael@0 | 11 | * and a directory service key. When used as a pref value, it stores a |
michael@0 | 12 | * relative path to the file from the location pointed to by the directory |
michael@0 | 13 | * service key. The path has the same syntax across all platforms. |
michael@0 | 14 | * |
michael@0 | 15 | * @see nsIPrefBranch::getComplexValue |
michael@0 | 16 | * @see nsIPrefBranch::setComplexValue |
michael@0 | 17 | * |
michael@0 | 18 | */ |
michael@0 | 19 | |
michael@0 | 20 | [scriptable, uuid(2f977d4e-5485-11d4-87e2-0010a4e75ef2)] |
michael@0 | 21 | interface nsIRelativeFilePref : nsISupports |
michael@0 | 22 | { |
michael@0 | 23 | /** |
michael@0 | 24 | * file |
michael@0 | 25 | * |
michael@0 | 26 | * The file whose location is stored or retrieved. |
michael@0 | 27 | */ |
michael@0 | 28 | attribute nsIFile file; |
michael@0 | 29 | |
michael@0 | 30 | /** |
michael@0 | 31 | * relativeToKey |
michael@0 | 32 | * |
michael@0 | 33 | * A directory service key for the directory |
michael@0 | 34 | * from which the file path is relative. |
michael@0 | 35 | */ |
michael@0 | 36 | attribute ACString relativeToKey; |
michael@0 | 37 | |
michael@0 | 38 | }; |
michael@0 | 39 | |
michael@0 | 40 | %{C++ |
michael@0 | 41 | |
michael@0 | 42 | #define NS_RELATIVEFILEPREF_CID \ |
michael@0 | 43 | { /* {2f977d4f-5485-11d4-87e2-0010a4e75ef2} */ \ |
michael@0 | 44 | 0x2f977d4f, \ |
michael@0 | 45 | 0x5485, \ |
michael@0 | 46 | 0x11d4, \ |
michael@0 | 47 | { 0x87, 0xe2, 0x00, 0x10, 0xa4, 0xe7, 0x5e, 0xf2 } \ |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | #define NS_RELATIVEFILEPREF_CONTRACTID "@mozilla.org/pref-relativefile;1" |
michael@0 | 51 | |
michael@0 | 52 | #include "nsComponentManagerUtils.h" |
michael@0 | 53 | |
michael@0 | 54 | inline nsresult |
michael@0 | 55 | NS_NewRelativeFilePref(nsIFile* aFile, const nsACString& relativeToKey, nsIRelativeFilePref** result) |
michael@0 | 56 | { |
michael@0 | 57 | nsresult rv; |
michael@0 | 58 | nsCOMPtr<nsIRelativeFilePref> local(do_CreateInstance(NS_RELATIVEFILEPREF_CONTRACTID, &rv)); |
michael@0 | 59 | if (NS_FAILED(rv)) return rv; |
michael@0 | 60 | |
michael@0 | 61 | (void)local->SetFile(aFile); |
michael@0 | 62 | (void)local->SetRelativeToKey(relativeToKey); |
michael@0 | 63 | |
michael@0 | 64 | *result = local; |
michael@0 | 65 | NS_ADDREF(*result); |
michael@0 | 66 | return NS_OK; |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | %} |