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 #include "mozilla/dom/OSFileSystem.h"
9 #include "mozilla/dom/Directory.h"
10 #include "mozilla/dom/File.h"
11 #include "mozilla/dom/FileSystemUtils.h"
12 #include "nsIGlobalObject.h"
17 namespace mozilla::dom
{
19 OSFileSystem::OSFileSystem(const nsAString
& aRootDir
) {
20 mLocalRootPath
= aRootDir
;
23 already_AddRefed
<FileSystemBase
> OSFileSystem::Clone() {
24 AssertIsOnOwningThread();
26 RefPtr
<OSFileSystem
> fs
= new OSFileSystem(mLocalRootPath
);
34 void OSFileSystem::Init(nsIGlobalObject
* aGlobal
) {
35 AssertIsOnOwningThread();
36 MOZ_ASSERT(!mGlobal
, "No duple Init() calls");
42 nsIGlobalObject
* OSFileSystem::GetParentObject() const {
43 AssertIsOnOwningThread();
47 bool OSFileSystem::IsSafeFile(nsIFile
* aFile
) const {
48 // The concept of "safe files" is specific to the Device Storage API where
49 // files are only "safe" if they're of a type that is appropriate for the
50 // area of device storage that is being used.
51 MOZ_CRASH("Don't use OSFileSystem with the Device Storage API");
55 bool OSFileSystem::IsSafeDirectory(Directory
* aDir
) const {
56 // The concept of "safe directory" is specific to the Device Storage API
57 // where a directory is only "safe" if it belongs to the area of device
58 // storage that it is being used with.
59 MOZ_CRASH("Don't use OSFileSystem with the Device Storage API");
63 void OSFileSystem::Unlink() {
64 AssertIsOnOwningThread();
68 void OSFileSystem::Traverse(nsCycleCollectionTraversalCallback
& cb
) {
69 AssertIsOnOwningThread();
71 OSFileSystem
* tmp
= this;
72 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGlobal
);
75 void OSFileSystem::SerializeDOMPath(nsAString
& aOutput
) const {
76 AssertIsOnOwningThread();
77 aOutput
= mLocalRootPath
;
84 OSFileSystemParent::OSFileSystemParent(const nsAString
& aRootDir
) {
85 mLocalRootPath
= aRootDir
;
88 } // namespace mozilla::dom