-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJSIL.ReadOnlyStorage.js
More file actions
49 lines (35 loc) · 1.19 KB
/
Copy pathJSIL.ReadOnlyStorage.js
File metadata and controls
49 lines (35 loc) · 1.19 KB
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
"use strict";
if (typeof (JSIL) === "undefined")
throw new Error("JSIL.Core required");
if (typeof ($jsilstorage) === "undefined")
throw new Error("JSIL.Storage required");
var $jsilreadonlystorage = JSIL.DeclareAssembly("JSIL.ReadOnlyStorage");
JSIL.MakeClass($jsilstorage.TypeRef("VirtualVolume"), "ReadOnlyStorageVolume", true, [], function ($) {
$.RawMethod(false, ".ctor", function (name, rootPath, initializer) {
this.fileBytes = {};
VirtualVolume.prototype._ctor.call(
this, name, rootPath
);
initializer(this);
this.readOnly = true;
});
$.RawMethod(false, "flush", function () {
});
$.RawMethod(false, "deleteFileBytes", function (name) {
if (this.readOnly)
throw new Error("Volume is read-only");
delete this.fileBytes[name];
});
$.RawMethod(false, "getFileBytes", function (name) {
return this.fileBytes[name];
});
$.RawMethod(false, "setFileBytes", function (name, value) {
if (this.readOnly)
throw new Error("Volume is read-only");
this.fileBytes[name] = value;
});
$.RawMethod(false, "toString", function () {
return "<ReadOnlyStorage Volume '" + this.name + "'>";
});
});
JSIL.ReadOnlyStorage = {};