|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* vim: set ts=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 file, |
|
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef mozilla_dom_FileSystemBase_h |
|
8 #define mozilla_dom_FileSystemBase_h |
|
9 |
|
10 #include "nsAutoPtr.h" |
|
11 #include "nsString.h" |
|
12 |
|
13 class nsIDOMFile; |
|
14 class nsPIDOMWindow; |
|
15 |
|
16 namespace mozilla { |
|
17 namespace dom { |
|
18 |
|
19 class Directory; |
|
20 |
|
21 class FileSystemBase |
|
22 { |
|
23 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FileSystemBase) |
|
24 public: |
|
25 |
|
26 // Create file system object from its string representation. |
|
27 static already_AddRefed<FileSystemBase> |
|
28 FromString(const nsAString& aString); |
|
29 |
|
30 FileSystemBase(); |
|
31 |
|
32 virtual void |
|
33 Shutdown(); |
|
34 |
|
35 // Get the string representation of the file system. |
|
36 const nsString& |
|
37 ToString() const |
|
38 { |
|
39 return mString; |
|
40 } |
|
41 |
|
42 virtual nsPIDOMWindow* |
|
43 GetWindow() const; |
|
44 |
|
45 /* |
|
46 * Create nsIFile object with the given real path (absolute DOM path). |
|
47 */ |
|
48 virtual already_AddRefed<nsIFile> |
|
49 GetLocalFile(const nsAString& aRealPath) const = 0; |
|
50 |
|
51 /* |
|
52 * Get the virtual name of the root directory. This name will be exposed to |
|
53 * the content page. |
|
54 */ |
|
55 virtual const nsAString& |
|
56 GetRootName() const = 0; |
|
57 |
|
58 bool |
|
59 IsShutdown() const |
|
60 { |
|
61 return mShutdown; |
|
62 } |
|
63 |
|
64 virtual bool |
|
65 IsSafeFile(nsIFile* aFile) const; |
|
66 |
|
67 virtual bool |
|
68 IsSafeDirectory(Directory* aDir) const; |
|
69 |
|
70 /* |
|
71 * Get the real path (absolute DOM path) of the DOM file in the file system. |
|
72 * If succeeded, returns true. Otherwise, returns false and set aRealPath to |
|
73 * empty string. |
|
74 */ |
|
75 virtual bool |
|
76 GetRealPath(nsIDOMFile* aFile, nsAString& aRealPath) const = 0; |
|
77 |
|
78 /* |
|
79 * Get the permission name required to access this file system. |
|
80 */ |
|
81 const nsCString& |
|
82 GetPermission() const |
|
83 { |
|
84 return mPermission; |
|
85 } |
|
86 |
|
87 bool |
|
88 IsTesting() const |
|
89 { |
|
90 return mIsTesting; |
|
91 } |
|
92 protected: |
|
93 virtual ~FileSystemBase(); |
|
94 |
|
95 // The string representation of the file system. |
|
96 nsString mString; |
|
97 |
|
98 bool mShutdown; |
|
99 |
|
100 // The permission name required to access the file system. |
|
101 nsCString mPermission; |
|
102 |
|
103 bool mIsTesting; |
|
104 }; |
|
105 |
|
106 } // namespace dom |
|
107 } // namespace mozilla |
|
108 |
|
109 #endif // mozilla_dom_FileSystemBase_h |