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