| 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(this, "", true, null); | 10 this.root = new InspectorTest.TestFileSystem.Entry(this, "", true, null); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 delete InspectorTest.TestFileSystem._instances[this.fileSystemPath]; | 40 delete InspectorTest.TestFileSystem._instances[this.fileSystemPath]; |
| 41 InspectorFrontendHost.events.dispatchEventToListeners(InspectorFrontendH
ostAPI.Events.FileSystemRemoved, this.fileSystemPath); | 41 InspectorFrontendHost.events.dispatchEventToListeners(InspectorFrontendH
ostAPI.Events.FileSystemRemoved, this.fileSystemPath); |
| 42 }, | 42 }, |
| 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 }, |
| 51 |
| 52 /** |
| 53 * @param {string} path |
| 54 * @param {string} content |
| 55 * @param {number} lastModified |
| 56 */ |
| 57 addFile: function(path, content, lastModified) |
| 58 { |
| 59 var pathTokens = path.split("/"); |
| 60 var node = this.root; |
| 61 var folders = pathTokens.slice(0, pathTokens.length - 1); |
| 62 var fileName = pathTokens.peekLast(); |
| 63 for (var folder of folders) { |
| 64 var dir = node._childrenMap[folder]; |
| 65 if (!dir) |
| 66 dir = node.mkdir(folder); |
| 67 node = dir; |
| 68 } |
| 69 var file = node.addFile(fileName, content); |
| 70 if (lastModified) |
| 71 file._timestamp = lastModified; |
| 72 return file; |
| 50 } | 73 } |
| 51 } | 74 } |
| 52 | 75 |
| 53 InspectorTest.TestFileSystem.Entry = function(fileSystem, name, isDirectory, par
ent) | 76 InspectorTest.TestFileSystem.Entry = function(fileSystem, name, isDirectory, par
ent) |
| 54 { | 77 { |
| 55 this._fileSystem = fileSystem; | 78 this._fileSystem = fileSystem; |
| 56 this.name = name; | 79 this.name = name; |
| 57 this._children = []; | 80 this._children = []; |
| 58 this._childrenMap = {}; | 81 this._childrenMap = {}; |
| 59 this.isDirectory = isDirectory; | 82 this.isDirectory = isDirectory; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 return child; | 119 return child; |
| 97 }, | 120 }, |
| 98 | 121 |
| 99 addFile: function(name, content) | 122 addFile: function(name, content) |
| 100 { | 123 { |
| 101 var child = new InspectorTest.TestFileSystem.Entry(this._fileSystem, nam
e, false, this); | 124 var child = new InspectorTest.TestFileSystem.Entry(this._fileSystem, nam
e, false, this); |
| 102 this._childrenMap[name] = child; | 125 this._childrenMap[name] = child; |
| 103 this._children.push(child); | 126 this._children.push(child); |
| 104 child.parent = this; | 127 child.parent = this; |
| 105 child.content = new Blob([content], {type: 'text/plain'}); | 128 child.content = new Blob([content], {type: 'text/plain'}); |
| 129 var fullPath = this._fileSystem.fileSystemPath + child.fullPath; |
| 130 InspectorFrontendHost.events.dispatchEventToListeners(InspectorFrontendH
ostAPI.Events.FileSystemFilesChanged, [fullPath]); |
| 106 return child; | 131 return child; |
| 107 }, | 132 }, |
| 108 | 133 |
| 109 setContent: function(content) | 134 setContent: function(content) |
| 110 { | 135 { |
| 111 this.content = new Blob([content], {type: 'text/plain'}); | 136 this.content = new Blob([content], {type: 'text/plain'}); |
| 112 this._timestamp += 1000; | 137 this._timestamp += 1000; |
| 113 var fullPath = this._fileSystem.fileSystemPath + this.fullPath; | 138 var fullPath = this._fileSystem.fileSystemPath + this.fullPath; |
| 114 InspectorFrontendHost.events.dispatchEventToListeners(InspectorFrontendH
ostAPI.Events.FileSystemFilesChanged, [fullPath]); | 139 InspectorFrontendHost.events.dispatchEventToListeners(InspectorFrontendH
ostAPI.Events.FileSystemFilesChanged, [fullPath]); |
| 115 }, | 140 }, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 truncate: function(num) | 233 truncate: function(num) |
| 209 { | 234 { |
| 210 this._entry._timestamp += this._modificationTimesDelta; | 235 this._entry._timestamp += this._modificationTimesDelta; |
| 211 this._entry.content = this._entry.content.slice(0, num); | 236 this._entry.content = this._entry.content.slice(0, num); |
| 212 if (this.onwriteend) | 237 if (this.onwriteend) |
| 213 this.onwriteend(); | 238 this.onwriteend(); |
| 214 } | 239 } |
| 215 } | 240 } |
| 216 | 241 |
| 217 }; | 242 }; |
| OLD | NEW |