FileSystemDirectoryEntry.h (2688B)
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::dom { 13 14 class Directory; 15 class FileSystemDirectoryReader; 16 17 class FileSystemDirectoryEntry : public FileSystemEntry { 18 public: 19 NS_DECL_ISUPPORTS_INHERITED 20 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(FileSystemDirectoryEntry, 21 FileSystemEntry) 22 23 FileSystemDirectoryEntry(nsIGlobalObject* aGlobalObject, 24 Directory* aDirectory, 25 FileSystemDirectoryEntry* aParentEntry, 26 FileSystem* aFileSystem); 27 28 virtual JSObject* WrapObject(JSContext* aCx, 29 JS::Handle<JSObject*> aGivenProto) override; 30 31 virtual bool IsDirectory() const override { return true; } 32 33 virtual void GetName(nsAString& aName, ErrorResult& aRv) const override; 34 35 virtual void GetFullPath(nsAString& aFullPath, 36 ErrorResult& aRv) const override; 37 38 virtual already_AddRefed<FileSystemDirectoryReader> CreateReader(); 39 40 void GetFile( 41 const Optional<nsAString>& aPath, const FileSystemFlags& aFlag, 42 const Optional<OwningNonNull<FileSystemEntryCallback>>& aSuccessCallback, 43 const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback) { 44 GetInternal(aPath.WasPassed() ? aPath.Value() : u""_ns, aFlag, 45 aSuccessCallback, aErrorCallback, eGetFile); 46 } 47 48 void GetDirectory( 49 const Optional<nsAString>& aPath, const FileSystemFlags& aFlag, 50 const Optional<OwningNonNull<FileSystemEntryCallback>>& aSuccessCallback, 51 const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback) { 52 GetInternal(aPath.WasPassed() ? aPath.Value() : u""_ns, aFlag, 53 aSuccessCallback, aErrorCallback, eGetDirectory); 54 } 55 56 enum GetInternalType { eGetFile, eGetDirectory }; 57 58 virtual void GetInternal( 59 const nsAString& aPath, const FileSystemFlags& aFlag, 60 const Optional<OwningNonNull<FileSystemEntryCallback>>& aSuccessCallback, 61 const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback, 62 GetInternalType aType); 63 64 protected: 65 virtual ~FileSystemDirectoryEntry(); 66 67 private: 68 RefPtr<Directory> mDirectory; 69 }; 70 71 } // namespace mozilla::dom 72 73 #endif // mozilla_dom_FileSystemDirectoryEntry_h