1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 
7 #ifndef nsDirectoryService_h___
8 #define nsDirectoryService_h___
9 
10 #include "nsIDirectoryService.h"
11 #include "nsInterfaceHashtable.h"
12 #include "nsIFile.h"
13 #include "nsDirectoryServiceDefs.h"
14 #include "nsTArray.h"
15 #include "mozilla/Attributes.h"
16 #include "mozilla/StaticPtr.h"
17 
18 #define NS_DIRECTORY_SERVICE_CID                     \
19   {                                                  \
20     0xf00152d0, 0xb40b, 0x11d3, {                    \
21       0x8c, 0x9c, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74 \
22     }                                                \
23   }
24 
25 class nsDirectoryService final : public nsIDirectoryService,
26                                  public nsIProperties,
27                                  public nsIDirectoryServiceProvider2 {
28  public:
29   NS_DECL_THREADSAFE_ISUPPORTS
30 
31   NS_DECL_NSIPROPERTIES
32 
33   NS_DECL_NSIDIRECTORYSERVICE
34 
35   NS_DECL_NSIDIRECTORYSERVICEPROVIDER
36 
37   NS_DECL_NSIDIRECTORYSERVICEPROVIDER2
38 
39   nsDirectoryService();
40 
41   static void RealInit();
42   void RegisterCategoryProviders();
43 
44   static nsresult Create(nsISupports* aOuter, REFNSIID aIID, void** aResult);
45 
46   static mozilla::StaticRefPtr<nsDirectoryService> gService;
47 
SetCurrentProcessDirectory(nsIFile * aFile)48   void SetCurrentProcessDirectory(nsIFile* aFile) { mXCurProcD = aFile; }
49   nsresult GetCurrentProcessDirectory(nsIFile**);
50 
51  private:
52   ~nsDirectoryService();
53   nsCOMPtr<nsIFile> mXCurProcD;
54 
55   nsInterfaceHashtable<nsCStringHashKey, nsIFile> mHashtable;
56   nsTArray<nsCOMPtr<nsIDirectoryServiceProvider>> mProviders;
57 };
58 
59 #endif
60