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/. */
7 #ifndef mozilla_dom_FileSystemBase_h
8 #define mozilla_dom_FileSystemBase_h
11 #include "Directory.h"
13 namespace mozilla::dom
{
17 class FileSystemBase
{
19 NS_INLINE_DECL_REFCOUNTING(FileSystemBase
)
23 virtual void Shutdown();
25 // SerializeDOMPath the FileSystem to string.
26 virtual void SerializeDOMPath(nsAString
& aOutput
) const = 0;
28 virtual already_AddRefed
<FileSystemBase
> Clone() = 0;
30 virtual bool ShouldCreateDirectory() = 0;
32 virtual nsIGlobalObject
* GetParentObject() const;
34 virtual void GetDirectoryName(nsIFile
* aFile
, nsAString
& aRetval
,
35 ErrorResult
& aRv
) const;
37 void GetDOMPath(nsIFile
* aFile
, nsAString
& aRetval
, ErrorResult
& aRv
) const;
40 * Return the local root path of the FileSystem implementation.
41 * For OSFileSystem, this is equal to the path of the root Directory;
42 * For DeviceStorageFileSystem, this is the path of the SDCard, parent
43 * directory of the exposed root Directory (per type).
45 const nsAString
& LocalRootPath() const { return mLocalRootPath
; }
47 bool IsShutdown() const { return mShutdown
; }
49 virtual bool IsSafeFile(nsIFile
* aFile
) const;
51 virtual bool IsSafeDirectory(Directory
* aDir
) const;
53 bool GetRealPath(BlobImpl
* aFile
, nsIFile
** aPath
) const;
56 virtual void Unlink() {}
57 virtual void Traverse(nsCycleCollectionTraversalCallback
& cb
) {}
59 void AssertIsOnOwningThread() const;
62 virtual ~FileSystemBase();
64 // The local path of the root (i.e. the OS path, with OS path separators, of
65 // the OS directory that acts as the root of this OSFileSystem).
66 // This path must be set by the FileSystem implementation immediately
67 // because it will be used for the validation of any FileSystemTaskChildBase.
68 // The concept of this path is that, any task will never go out of it and this
69 // must be considered the OS 'root' of the current FileSystem. Different
70 // Directory object can have different OS 'root' path.
71 // To be more clear, any path managed by this FileSystem implementation must
72 // be discendant of this local root path.
73 nsString mLocalRootPath
;
78 } // namespace mozilla::dom
80 #endif // mozilla_dom_FileSystemBase_h