michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_Directory_h michael@0: #define mozilla_dom_Directory_h michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "mozilla/dom/BindingDeclarations.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "nsCycleCollectionParticipant.h" michael@0: #include "nsDOMFile.h" michael@0: #include "nsPIDOMWindow.h" michael@0: #include "nsWrapperCache.h" michael@0: michael@0: // Resolve the name collision of Microsoft's API name with macros defined in michael@0: // Windows header files. Undefine the macro of CreateDirectory to avoid michael@0: // Directory#CreateDirectory being replaced by Directory#CreateDirectoryW. michael@0: #ifdef CreateDirectory michael@0: #undef CreateDirectory michael@0: #endif michael@0: // Undefine the macro of CreateFile to avoid Directory#CreateFile being replaced michael@0: // by Directory#CreateFileW. michael@0: #ifdef CreateFile michael@0: #undef CreateFile michael@0: #endif michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: class CreateFileOptions; michael@0: class FileSystemBase; michael@0: class Promise; michael@0: class StringOrFileOrDirectory; michael@0: michael@0: class Directory MOZ_FINAL michael@0: : public nsISupports michael@0: , public nsWrapperCache michael@0: { michael@0: public: michael@0: NS_DECL_CYCLE_COLLECTING_ISUPPORTS michael@0: NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Directory) michael@0: michael@0: public: michael@0: static already_AddRefed michael@0: GetRoot(FileSystemBase* aFileSystem); michael@0: michael@0: Directory(FileSystemBase* aFileSystem, const nsAString& aPath); michael@0: ~Directory(); michael@0: michael@0: // ========= Begin WebIDL bindings. =========== michael@0: michael@0: nsPIDOMWindow* michael@0: GetParentObject() const; michael@0: michael@0: virtual JSObject* michael@0: WrapObject(JSContext* aCx) MOZ_OVERRIDE; michael@0: michael@0: void michael@0: GetName(nsString& aRetval) const; michael@0: michael@0: already_AddRefed michael@0: CreateFile(const nsAString& aPath, const CreateFileOptions& aOptions); michael@0: michael@0: already_AddRefed michael@0: CreateDirectory(const nsAString& aPath); michael@0: michael@0: already_AddRefed michael@0: Get(const nsAString& aPath); michael@0: michael@0: already_AddRefed michael@0: Remove(const StringOrFileOrDirectory& aPath); michael@0: michael@0: already_AddRefed michael@0: RemoveDeep(const StringOrFileOrDirectory& aPath); michael@0: michael@0: // =========== End WebIDL bindings.============ michael@0: michael@0: FileSystemBase* michael@0: GetFileSystem() const; michael@0: private: michael@0: static bool michael@0: IsValidRelativePath(const nsString& aPath); michael@0: michael@0: /* michael@0: * Convert relative DOM path to the absolute real path. michael@0: * @return true if succeed. false if the DOM path is invalid. michael@0: */ michael@0: bool michael@0: DOMPathToRealPath(const nsAString& aPath, nsAString& aRealPath) const; michael@0: michael@0: already_AddRefed michael@0: RemoveInternal(const StringOrFileOrDirectory& aPath, bool aRecursive); michael@0: michael@0: nsRefPtr mFileSystem; michael@0: nsString mPath; michael@0: }; michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: #endif // mozilla_dom_Directory_h