nsIRelativeFilePref.idl 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. #include "nsISupports.idl"
  6. interface nsIFile;
  7. /**
  8. * The nsIRelativeFilePref interface is a wrapper for an nsIFile and
  9. * and a directory service key. When used as a pref value, it stores a
  10. * relative path to the file from the location pointed to by the directory
  11. * service key. The path has the same syntax across all platforms.
  12. *
  13. * @see nsIPrefBranch::getComplexValue
  14. * @see nsIPrefBranch::setComplexValue
  15. *
  16. */
  17. [scriptable, uuid(2f977d4e-5485-11d4-87e2-0010a4e75ef2)]
  18. interface nsIRelativeFilePref : nsISupports
  19. {
  20. /**
  21. * file
  22. *
  23. * The file whose location is stored or retrieved.
  24. */
  25. attribute nsIFile file;
  26. /**
  27. * relativeToKey
  28. *
  29. * A directory service key for the directory
  30. * from which the file path is relative.
  31. */
  32. attribute ACString relativeToKey;
  33. };
  34. %{C++
  35. #define NS_RELATIVEFILEPREF_CID \
  36. { /* {2f977d4f-5485-11d4-87e2-0010a4e75ef2} */ \
  37. 0x2f977d4f, \
  38. 0x5485, \
  39. 0x11d4, \
  40. { 0x87, 0xe2, 0x00, 0x10, 0xa4, 0xe7, 0x5e, 0xf2 } \
  41. }
  42. #define NS_RELATIVEFILEPREF_CONTRACTID "@mozilla.org/pref-relativefile;1"
  43. #include "nsComponentManagerUtils.h"
  44. inline nsresult
  45. NS_NewRelativeFilePref(nsIFile* aFile, const nsACString& relativeToKey, nsIRelativeFilePref** result)
  46. {
  47. nsresult rv;
  48. nsCOMPtr<nsIRelativeFilePref> local(do_CreateInstance(NS_RELATIVEFILEPREF_CONTRACTID, &rv));
  49. if (NS_FAILED(rv)) return rv;
  50. (void)local->SetFile(aFile);
  51. (void)local->SetRelativeToKey(relativeToKey);
  52. *result = local;
  53. NS_ADDREF(*result);
  54. return NS_OK;
  55. }
  56. %}