forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 2
/
FileSystemBase.h
127 lines (98 loc) · 2.83 KB
/
FileSystemBase.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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 "nsAutoPtr.h"
#include "nsString.h"
class nsPIDOMWindow;
namespace mozilla {
namespace dom {
class BlobImpl;
class Directory;
class FileSystemBase
{
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FileSystemBase)
public:
// Create file system object from its string representation.
static already_AddRefed<FileSystemBase>
FromString(const nsAString& aString);
FileSystemBase();
virtual void
Shutdown();
// Get the string representation of the file system.
const nsString&
ToString() const
{
return mString;
}
virtual nsPIDOMWindow*
GetWindow() const;
/**
* Create nsIFile object from the given real path (absolute DOM path).
*/
already_AddRefed<nsIFile>
GetLocalFile(const nsAString& aRealPath) const;
/*
* Get the virtual name of the root directory. This name will be exposed to
* the content page.
*/
virtual void
GetRootName(nsAString& aRetval) const = 0;
const nsAString&
GetLocalRootPath() const
{
return mLocalRootPath;
}
bool
IsShutdown() const
{
return mShutdown;
}
virtual bool
IsSafeFile(nsIFile* aFile) const;
virtual bool
IsSafeDirectory(Directory* aDir) const;
/*
* Get the real path (absolute DOM path) of the DOM file in the file system.
* If succeeded, returns true. Otherwise, returns false and set aRealPath to
* empty string.
*/
bool
GetRealPath(BlobImpl* aFile, nsAString& aRealPath) const;
/*
* Get the permission name required to access this file system.
*/
const nsCString&
GetPermission() const
{
return mPermission;
}
bool
RequiresPermissionChecks() const
{
return mRequiresPermissionChecks;
}
protected:
virtual ~FileSystemBase();
bool
LocalPathToRealPath(const nsAString& aLocalPath, nsAString& aRealPath) const;
// 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).
// Only available in the parent process.
// In the child process, we don't use it and its value should be empty.
nsString mLocalRootPath;
// The same, but with path separators normalized to "/".
nsString mNormalizedLocalRootPath;
// The string representation of the file system.
nsString mString;
bool mShutdown;
// The permission name required to access the file system.
nsCString mPermission;
bool mRequiresPermissionChecks;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_FileSystemBase_h