Bumping manifests a=b2g-bump
[gecko.git] / dom / filesystem / Directory.h
blob5bd8c7dcef24b05cda3d7f74979238f0892b4068
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/. */
7 #ifndef mozilla_dom_Directory_h
8 #define mozilla_dom_Directory_h
10 #include "mozilla/Attributes.h"
11 #include "mozilla/ErrorResult.h"
12 #include "mozilla/dom/BindingDeclarations.h"
13 #include "nsAutoPtr.h"
14 #include "nsCycleCollectionParticipant.h"
15 #include "nsDOMFile.h"
16 #include "nsPIDOMWindow.h"
17 #include "nsWrapperCache.h"
19 // Resolve the name collision of Microsoft's API name with macros defined in
20 // Windows header files. Undefine the macro of CreateDirectory to avoid
21 // Directory#CreateDirectory being replaced by Directory#CreateDirectoryW.
22 #ifdef CreateDirectory
23 #undef CreateDirectory
24 #endif
25 // Undefine the macro of CreateFile to avoid Directory#CreateFile being replaced
26 // by Directory#CreateFileW.
27 #ifdef CreateFile
28 #undef CreateFile
29 #endif
31 namespace mozilla {
32 namespace dom {
34 struct CreateFileOptions;
35 class FileSystemBase;
36 class Promise;
37 class StringOrFileOrDirectory;
39 class Directory MOZ_FINAL
40 : public nsISupports
41 , public nsWrapperCache
43 public:
44 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
45 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Directory)
47 public:
48 static already_AddRefed<Promise>
49 GetRoot(FileSystemBase* aFileSystem, ErrorResult& aRv);
51 Directory(FileSystemBase* aFileSystem, const nsAString& aPath);
53 // ========= Begin WebIDL bindings. ===========
55 nsPIDOMWindow*
56 GetParentObject() const;
58 virtual JSObject*
59 WrapObject(JSContext* aCx) MOZ_OVERRIDE;
61 void
62 GetName(nsString& aRetval) const;
64 already_AddRefed<Promise>
65 CreateFile(const nsAString& aPath, const CreateFileOptions& aOptions,
66 ErrorResult& aRv);
68 already_AddRefed<Promise>
69 CreateDirectory(const nsAString& aPath, ErrorResult& aRv);
71 already_AddRefed<Promise>
72 Get(const nsAString& aPath, ErrorResult& aRv);
74 already_AddRefed<Promise>
75 Remove(const StringOrFileOrDirectory& aPath, ErrorResult& aRv);
77 already_AddRefed<Promise>
78 RemoveDeep(const StringOrFileOrDirectory& aPath, ErrorResult& aRv);
80 // =========== End WebIDL bindings.============
82 FileSystemBase*
83 GetFileSystem() const;
84 private:
85 ~Directory();
87 static bool
88 IsValidRelativePath(const nsString& aPath);
91 * Convert relative DOM path to the absolute real path.
92 * @return true if succeed. false if the DOM path is invalid.
94 bool
95 DOMPathToRealPath(const nsAString& aPath, nsAString& aRealPath) const;
97 already_AddRefed<Promise>
98 RemoveInternal(const StringOrFileOrDirectory& aPath, bool aRecursive,
99 ErrorResult& aRv);
101 nsRefPtr<FileSystemBase> mFileSystem;
102 nsString mPath;
105 } // namespace dom
106 } // namespace mozilla
108 #endif // mozilla_dom_Directory_h