Line data Source code
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 file,
5 : * You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef mozilla_dom_FileSystemDirectoryEntry_h
8 : #define mozilla_dom_FileSystemDirectoryEntry_h
9 :
10 : #include "mozilla/dom/FileSystemEntry.h"
11 :
12 : namespace mozilla {
13 : namespace dom {
14 :
15 : class Directory;
16 : class FileSystemDirectoryReader;
17 :
18 : class FileSystemDirectoryEntry : public FileSystemEntry
19 : {
20 : public:
21 : NS_DECL_ISUPPORTS_INHERITED
22 0 : NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(FileSystemDirectoryEntry,
23 : FileSystemEntry)
24 :
25 : FileSystemDirectoryEntry(nsIGlobalObject* aGlobalObject,
26 : Directory* aDirectory,
27 : FileSystemDirectoryEntry* aParentEntry,
28 : FileSystem* aFileSystem);
29 :
30 : virtual JSObject*
31 : WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
32 :
33 : virtual bool
34 0 : IsDirectory() const override
35 : {
36 0 : return true;
37 : }
38 :
39 : virtual void
40 : GetName(nsAString& aName, ErrorResult& aRv) const override;
41 :
42 : virtual void
43 : GetFullPath(nsAString& aFullPath, ErrorResult& aRv) const override;
44 :
45 : virtual already_AddRefed<FileSystemDirectoryReader>
46 : CreateReader();
47 :
48 : void
49 0 : GetFile(const Optional<nsAString>& aPath, const FileSystemFlags& aFlag,
50 : const Optional<OwningNonNull<FileSystemEntryCallback>>& aSuccessCallback,
51 : const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback)
52 : {
53 0 : GetInternal(aPath.WasPassed() ? aPath.Value() : EmptyString(),
54 0 : aFlag, aSuccessCallback, aErrorCallback, eGetFile);
55 0 : }
56 :
57 : void
58 0 : GetDirectory(const Optional<nsAString>& aPath, const FileSystemFlags& aFlag,
59 : const Optional<OwningNonNull<FileSystemEntryCallback>>& aSuccessCallback,
60 : const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback)
61 : {
62 0 : GetInternal(aPath.WasPassed() ? aPath.Value() : EmptyString(),
63 0 : aFlag, aSuccessCallback, aErrorCallback, eGetDirectory);
64 0 : }
65 :
66 : enum GetInternalType { eGetFile, eGetDirectory };
67 :
68 : virtual void
69 : GetInternal(const nsAString& aPath, const FileSystemFlags& aFlag,
70 : const Optional<OwningNonNull<FileSystemEntryCallback>>& aSuccessCallback,
71 : const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback,
72 : GetInternalType aType);
73 :
74 : protected:
75 : virtual ~FileSystemDirectoryEntry();
76 :
77 : private:
78 : RefPtr<Directory> mDirectory;
79 : };
80 :
81 : } // namespace dom
82 : } // namespace mozilla
83 :
84 : #endif // mozilla_dom_FileSystemDirectoryEntry_h
|