2014-03-05 07:25:40 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2015-05-03 22:32:37 +03:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2014-03-05 07:25:40 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_FileSystemBase_h
|
|
|
|
#define mozilla_dom_FileSystemBase_h
|
|
|
|
|
|
|
|
#include "nsString.h"
|
2016-03-30 09:17:56 +03:00
|
|
|
#include "Directory.h"
|
2014-03-05 07:25:40 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2015-05-12 15:11:03 +03:00
|
|
|
class BlobImpl;
|
2014-03-12 10:30:21 +04:00
|
|
|
|
2014-03-05 07:25:40 +04:00
|
|
|
class FileSystemBase {
|
|
|
|
public:
|
2016-04-09 21:17:02 +03:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(FileSystemBase)
|
2014-03-05 07:25:40 +04:00
|
|
|
|
|
|
|
FileSystemBase();
|
|
|
|
|
|
|
|
virtual void Shutdown();
|
|
|
|
|
2016-03-20 13:56:10 +03:00
|
|
|
// SerializeDOMPath the FileSystem to string.
|
|
|
|
virtual void SerializeDOMPath(nsAString& aOutput) const = 0;
|
2016-03-20 05:44:22 +03:00
|
|
|
|
2016-03-20 13:58:01 +03:00
|
|
|
virtual already_AddRefed<FileSystemBase> Clone() = 0;
|
|
|
|
|
2016-04-18 10:32:59 +03:00
|
|
|
virtual bool ShouldCreateDirectory() = 0;
|
|
|
|
|
2019-10-21 08:33:33 +03:00
|
|
|
virtual nsIGlobalObject* GetParentObject() const;
|
2014-03-05 07:25:40 +04:00
|
|
|
|
2016-04-18 10:32:30 +03:00
|
|
|
virtual void GetDirectoryName(nsIFile* aFile, nsAString& aRetval,
|
|
|
|
ErrorResult& aRv) const;
|
2014-03-05 07:25:40 +04:00
|
|
|
|
2016-04-18 10:32:30 +03:00
|
|
|
void GetDOMPath(nsIFile* aFile, nsAString& aRetval, ErrorResult& aRv) const;
|
2016-03-30 09:17:56 +03:00
|
|
|
|
2016-03-30 09:17:15 +03:00
|
|
|
/*
|
|
|
|
* Return the local root path of the FileSystem implementation.
|
|
|
|
* For OSFileSystem, this is equal to the path of the root Directory;
|
|
|
|
* For DeviceStorageFileSystem, this is the path of the SDCard, parent
|
|
|
|
* directory of the exposed root Directory (per type).
|
|
|
|
*/
|
2017-03-08 22:15:45 +03:00
|
|
|
const nsAString& LocalRootPath() const { return mLocalRootPath; }
|
2015-07-10 20:55:52 +03:00
|
|
|
|
2014-03-05 07:25:40 +04:00
|
|
|
bool IsShutdown() const { return mShutdown; }
|
2014-03-05 07:24:19 +04:00
|
|
|
|
|
|
|
virtual bool IsSafeFile(nsIFile* aFile) const;
|
|
|
|
|
2014-03-12 10:30:21 +04:00
|
|
|
virtual bool IsSafeDirectory(Directory* aDir) const;
|
|
|
|
|
2016-03-20 13:56:10 +03:00
|
|
|
bool GetRealPath(BlobImpl* aFile, nsIFile** aPath) const;
|
2014-03-12 10:30:21 +04:00
|
|
|
|
2015-12-30 11:53:38 +03:00
|
|
|
// CC methods
|
|
|
|
virtual void Unlink() {}
|
|
|
|
virtual void Traverse(nsCycleCollectionTraversalCallback& cb) {}
|
|
|
|
|
2016-04-09 21:17:02 +03:00
|
|
|
void AssertIsOnOwningThread() const;
|
|
|
|
|
2014-03-05 07:25:40 +04:00
|
|
|
protected:
|
|
|
|
virtual ~FileSystemBase();
|
|
|
|
|
2015-07-10 20:54:53 +03:00
|
|
|
// The local path of the root (i.e. the OS path, with OS path separators, of
|
|
|
|
// the OS directory that acts as the root of this OSFileSystem).
|
2016-03-30 09:17:15 +03:00
|
|
|
// This path must be set by the FileSystem implementation immediately
|
2016-04-09 21:17:28 +03:00
|
|
|
// because it will be used for the validation of any FileSystemTaskChildBase.
|
2016-03-30 09:17:15 +03:00
|
|
|
// The concept of this path is that, any task will never go out of it and this
|
|
|
|
// must be considered the OS 'root' of the current FileSystem. Different
|
|
|
|
// Directory object can have different OS 'root' path.
|
|
|
|
// To be more clear, any path managed by this FileSystem implementation must
|
|
|
|
// be discendant of this local root path.
|
2017-03-08 22:15:45 +03:00
|
|
|
nsString mLocalRootPath;
|
2015-07-10 20:54:53 +03:00
|
|
|
|
2014-03-05 07:25:40 +04:00
|
|
|
bool mShutdown;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_FileSystemBase_h
|