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_FileSystemBase_h michael@0: #define mozilla_dom_FileSystemBase_h michael@0: michael@0: #include "nsAutoPtr.h" michael@0: #include "nsString.h" michael@0: michael@0: class nsIDOMFile; michael@0: class nsPIDOMWindow; michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: class Directory; michael@0: michael@0: class FileSystemBase michael@0: { michael@0: NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FileSystemBase) michael@0: public: michael@0: michael@0: // Create file system object from its string representation. michael@0: static already_AddRefed michael@0: FromString(const nsAString& aString); michael@0: michael@0: FileSystemBase(); michael@0: michael@0: virtual void michael@0: Shutdown(); michael@0: michael@0: // Get the string representation of the file system. michael@0: const nsString& michael@0: ToString() const michael@0: { michael@0: return mString; michael@0: } michael@0: michael@0: virtual nsPIDOMWindow* michael@0: GetWindow() const; michael@0: michael@0: /* michael@0: * Create nsIFile object with the given real path (absolute DOM path). michael@0: */ michael@0: virtual already_AddRefed michael@0: GetLocalFile(const nsAString& aRealPath) const = 0; michael@0: michael@0: /* michael@0: * Get the virtual name of the root directory. This name will be exposed to michael@0: * the content page. michael@0: */ michael@0: virtual const nsAString& michael@0: GetRootName() const = 0; michael@0: michael@0: bool michael@0: IsShutdown() const michael@0: { michael@0: return mShutdown; michael@0: } michael@0: michael@0: virtual bool michael@0: IsSafeFile(nsIFile* aFile) const; michael@0: michael@0: virtual bool michael@0: IsSafeDirectory(Directory* aDir) const; michael@0: michael@0: /* michael@0: * Get the real path (absolute DOM path) of the DOM file in the file system. michael@0: * If succeeded, returns true. Otherwise, returns false and set aRealPath to michael@0: * empty string. michael@0: */ michael@0: virtual bool michael@0: GetRealPath(nsIDOMFile* aFile, nsAString& aRealPath) const = 0; michael@0: michael@0: /* michael@0: * Get the permission name required to access this file system. michael@0: */ michael@0: const nsCString& michael@0: GetPermission() const michael@0: { michael@0: return mPermission; michael@0: } michael@0: michael@0: bool michael@0: IsTesting() const michael@0: { michael@0: return mIsTesting; michael@0: } michael@0: protected: michael@0: virtual ~FileSystemBase(); michael@0: michael@0: // The string representation of the file system. michael@0: nsString mString; michael@0: michael@0: bool mShutdown; michael@0: michael@0: // The permission name required to access the file system. michael@0: nsCString mPermission; michael@0: michael@0: bool mIsTesting; michael@0: }; michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: #endif // mozilla_dom_FileSystemBase_h