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