OLD | NEW |
1 var initialize_IsolatedFileSystemTest = function() { | 1 var initialize_IsolatedFileSystemTest = function() { |
2 | 2 |
3 InspectorFrontendHost.isolatedFileSystem = function(name) | 3 InspectorFrontendHost.isolatedFileSystem = function(name) |
4 { | 4 { |
5 return InspectorTest.TestFileSystem._instances[name]; | 5 return InspectorTest.TestFileSystem._instances[name]; |
6 } | 6 } |
7 | 7 |
8 InspectorTest.TestFileSystem = function(fileSystemPath) | 8 InspectorTest.TestFileSystem = function(fileSystemPath) |
9 { | 9 { |
10 this.root = new InspectorTest.TestFileSystem.Entry("", true, null); | 10 this.root = new InspectorTest.TestFileSystem.Entry(this, "", true, null); |
11 this.fileSystemPath = fileSystemPath; | 11 this.fileSystemPath = fileSystemPath; |
12 } | 12 } |
13 | 13 |
14 InspectorTest.TestFileSystem._instances = {}; | 14 InspectorTest.TestFileSystem._instances = {}; |
15 | 15 |
16 InspectorTest.TestFileSystem.prototype = { | 16 InspectorTest.TestFileSystem.prototype = { |
17 reportCreated: function(callback) | 17 reportCreated: function(callback) |
18 { | 18 { |
19 var fileSystemPath = this.fileSystemPath; | 19 var fileSystemPath = this.fileSystemPath; |
20 InspectorTest.TestFileSystem._instances[this.fileSystemPath] = this; | 20 InspectorTest.TestFileSystem._instances[this.fileSystemPath] = this; |
(...skipping 22 matching lines...) Expand all Loading... |
43 | 43 |
44 addFileMapping: function(urlPrefix, pathPrefix) | 44 addFileMapping: function(urlPrefix, pathPrefix) |
45 { | 45 { |
46 var fileSystemMapping = new WebInspector.FileSystemMapping(); | 46 var fileSystemMapping = new WebInspector.FileSystemMapping(); |
47 fileSystemMapping.addFileSystem(this.fileSystemPath); | 47 fileSystemMapping.addFileSystem(this.fileSystemPath); |
48 fileSystemMapping.addFileMapping(this.fileSystemPath, urlPrefix, pathPre
fix); | 48 fileSystemMapping.addFileMapping(this.fileSystemPath, urlPrefix, pathPre
fix); |
49 WebInspector.fileSystemMapping._loadFromSettings(); | 49 WebInspector.fileSystemMapping._loadFromSettings(); |
50 } | 50 } |
51 } | 51 } |
52 | 52 |
53 InspectorTest.TestFileSystem.Entry = function(name, isDirectory, parent) | 53 InspectorTest.TestFileSystem.Entry = function(fileSystem, name, isDirectory, par
ent) |
54 { | 54 { |
| 55 this._fileSystem = fileSystem; |
55 this.name = name; | 56 this.name = name; |
56 this._children = []; | 57 this._children = []; |
57 this._childrenMap = {}; | 58 this._childrenMap = {}; |
58 this.isDirectory = isDirectory; | 59 this.isDirectory = isDirectory; |
59 this._timestamp = 1000000; | 60 this._timestamp = 1000000; |
60 this._parent = parent; | 61 this._parent = parent; |
61 } | 62 } |
62 | 63 |
63 InspectorTest.TestFileSystem.Entry.prototype = { | 64 InspectorTest.TestFileSystem.Entry.prototype = { |
64 get fullPath() | 65 get fullPath() |
65 { | 66 { |
66 return this.parent ? this.parent.fullPath + "/" + this.name : ""; | 67 return this.parent ? this.parent.fullPath + "/" + this.name : ""; |
67 }, | 68 }, |
68 | 69 |
| 70 remove: function(success, failure) |
| 71 { |
| 72 this._parent._removeChild(this, success, failure); |
| 73 }, |
| 74 |
| 75 _removeChild: function(child, success, failure) |
| 76 { |
| 77 var index = this._children.indexOf(child); |
| 78 if (index === -1) { |
| 79 failure("Failed to remove file: file not found."); |
| 80 return; |
| 81 } |
| 82 var fullPath = this._fileSystem.fileSystemPath + child.fullPath; |
| 83 this._children.splice(index, 1); |
| 84 delete this._childrenMap[child.name]; |
| 85 child.parent = null; |
| 86 InspectorFrontendHost.events.dispatchEventToListeners(InspectorFrontendH
ostAPI.Events.FileSystemFilesChanged, [fullPath]); |
| 87 success(); |
| 88 }, |
| 89 |
69 mkdir: function(name) | 90 mkdir: function(name) |
70 { | 91 { |
71 var child = new InspectorTest.TestFileSystem.Entry(name, true, this); | 92 var child = new InspectorTest.TestFileSystem.Entry(this._fileSystem, nam
e, true, this); |
72 this._childrenMap[name] = child; | 93 this._childrenMap[name] = child; |
73 this._children.push(child); | 94 this._children.push(child); |
74 child.parent = this; | 95 child.parent = this; |
75 return child; | 96 return child; |
76 }, | 97 }, |
77 | 98 |
78 addFile: function(name, content) | 99 addFile: function(name, content) |
79 { | 100 { |
80 var child = new InspectorTest.TestFileSystem.Entry(name, false, this); | 101 var child = new InspectorTest.TestFileSystem.Entry(this._fileSystem, nam
e, false, this); |
81 this._childrenMap[name] = child; | 102 this._childrenMap[name] = child; |
82 this._children.push(child); | 103 this._children.push(child); |
83 child.parent = this; | 104 child.parent = this; |
84 child.content = new Blob([content], {type: 'text/plain'}); | 105 child.content = new Blob([content], {type: 'text/plain'}); |
| 106 return child; |
85 }, | 107 }, |
86 | 108 |
87 createReader: function() | 109 createReader: function() |
88 { | 110 { |
89 return new InspectorTest.TestFileSystem.Reader(this._children); | 111 return new InspectorTest.TestFileSystem.Reader(this._children); |
90 }, | 112 }, |
91 | 113 |
92 createWriter: function(success, failure) | 114 createWriter: function(success, failure) |
93 { | 115 { |
94 success(new InspectorTest.TestFileSystem.Writer(this)); | 116 success(new InspectorTest.TestFileSystem.Writer(this)); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 truncate: function(num) | 200 truncate: function(num) |
179 { | 201 { |
180 this._entry._timestamp += this._modificationTimesDelta; | 202 this._entry._timestamp += this._modificationTimesDelta; |
181 this._entry.content = this._entry.content.slice(0, num); | 203 this._entry.content = this._entry.content.slice(0, num); |
182 if (this.onwriteend) | 204 if (this.onwriteend) |
183 this.onwriteend(); | 205 this.onwriteend(); |
184 } | 206 } |
185 } | 207 } |
186 | 208 |
187 }; | 209 }; |
OLD | NEW |