OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 22 matching lines...) Expand all Loading... | |
33 * @param {!WebInspector.IsolatedFileSystemManager} manager | 33 * @param {!WebInspector.IsolatedFileSystemManager} manager |
34 * @param {string} path | 34 * @param {string} path |
35 * @param {string} name | 35 * @param {string} name |
36 * @param {string} rootURL | 36 * @param {string} rootURL |
37 */ | 37 */ |
38 WebInspector.IsolatedFileSystem = function(manager, path, name, rootURL) | 38 WebInspector.IsolatedFileSystem = function(manager, path, name, rootURL) |
39 { | 39 { |
40 this._manager = manager; | 40 this._manager = manager; |
41 this._path = path; | 41 this._path = path; |
42 this._domFileSystem = InspectorFrontendHost.isolatedFileSystem(name, rootURL ); | 42 this._domFileSystem = InspectorFrontendHost.isolatedFileSystem(name, rootURL ); |
43 this._excludedFoldersSetting = WebInspector.settings.createLocalSetting("wor kspaceExcludedFolders", {}); | |
44 this._excludedFolders = this._excludedFoldersSetting.get()[path] || []; | |
dgozman
2015/09/26 01:46:41
Note that you modify setting value in place with a
| |
43 } | 45 } |
44 | 46 |
45 /** | 47 /** |
46 * @param {!FileError} error | 48 * @param {!FileError} error |
47 * @return {string} | 49 * @return {string} |
48 */ | 50 */ |
49 WebInspector.IsolatedFileSystem.errorMessage = function(error) | 51 WebInspector.IsolatedFileSystem.errorMessage = function(error) |
50 { | 52 { |
51 return WebInspector.UIString("File system error: %s", error.message); | 53 return WebInspector.UIString("File system error: %s", error.message); |
52 } | 54 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 | 96 |
95 /** | 97 /** |
96 * @param {!Array.<!FileEntry>} entries | 98 * @param {!Array.<!FileEntry>} entries |
97 * @this {WebInspector.IsolatedFileSystem} | 99 * @this {WebInspector.IsolatedFileSystem} |
98 */ | 100 */ |
99 function innerCallback(entries) | 101 function innerCallback(entries) |
100 { | 102 { |
101 for (var i = 0; i < entries.length; ++i) { | 103 for (var i = 0; i < entries.length; ++i) { |
102 var entry = entries[i]; | 104 var entry = entries[i]; |
103 if (!entry.isDirectory) { | 105 if (!entry.isDirectory) { |
104 if (this._manager.excludedFolderManager().isFileExcluded(thi s._path, entry.fullPath)) | 106 if (this._isFileExcluded(entry.fullPath)) |
105 continue; | 107 continue; |
106 fileCallback(entry.fullPath.substr(1)); | 108 fileCallback(entry.fullPath.substr(1)); |
107 } | 109 } |
108 else { | 110 else { |
109 if (this._manager.excludedFolderManager().isFileExcluded(thi s._path, entry.fullPath + "/")) | 111 if (this._isFileExcluded(entry.fullPath + "/")) |
110 continue; | 112 continue; |
111 ++pendingRequests; | 113 ++pendingRequests; |
112 this._requestEntries(entry.fullPath, innerCallback.bind(this )); | 114 this._requestEntries(entry.fullPath, innerCallback.bind(this )); |
113 } | 115 } |
114 } | 116 } |
115 if (finishedCallback && (--pendingRequests === 0)) | 117 if (finishedCallback && (--pendingRequests === 0)) |
116 finishedCallback(); | 118 finishedCallback(); |
117 } | 119 } |
118 }, | 120 }, |
119 | 121 |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
480 { | 482 { |
481 this._readDirectory(dirEntry, callback); | 483 this._readDirectory(dirEntry, callback); |
482 } | 484 } |
483 | 485 |
484 function errorHandler(error) | 486 function errorHandler(error) |
485 { | 487 { |
486 var errorMessage = WebInspector.IsolatedFileSystem.errorMessage(erro r); | 488 var errorMessage = WebInspector.IsolatedFileSystem.errorMessage(erro r); |
487 console.error(errorMessage + " when requesting entry '" + path + "'" ); | 489 console.error(errorMessage + " when requesting entry '" + path + "'" ); |
488 callback([]); | 490 callback([]); |
489 } | 491 } |
492 }, | |
493 | |
494 _saveExcludedFolders: function() | |
495 { | |
496 var settingValue = this._excludedFoldersSetting.get(); | |
497 settingValue[this._path] = this._excludedFolders; | |
498 this._excludedFoldersSetting.set(settingValue); | |
499 }, | |
500 | |
501 /** | |
502 * @param {string} path | |
503 */ | |
504 addExcludedFolder: function(path) | |
505 { | |
506 this._excludedFolders.push(path); | |
507 this._saveExcludedFolders(); | |
508 this._manager.dispatchEventToListeners(WebInspector.IsolatedFileSystemMa nager.Events.ExcludedFolderAdded, path); | |
509 }, | |
510 | |
511 /** | |
512 * @param {string} path | |
513 */ | |
514 removeExcludedFolder: function(path) | |
515 { | |
516 this._excludedFolders.remove(path); | |
517 this._saveExcludedFolders(); | |
518 this._manager.dispatchEventToListeners(WebInspector.IsolatedFileSystemMa nager.Events.ExcludedFolderRemoved, path); | |
519 }, | |
520 | |
521 fileSystemRemoved: function() | |
522 { | |
523 var settingValue = this._excludedFoldersSetting.get(); | |
524 delete settingValue[this._path]; | |
525 this._excludedFoldersSetting.set(settingValue); | |
526 }, | |
527 | |
528 /** | |
529 * @param {string} folderPath | |
530 * @return {boolean} | |
531 */ | |
532 _isFileExcluded: function(folderPath) | |
533 { | |
534 for (var i = 0; i < this._excludedFolders.length; ++i) { | |
535 if (this._excludedFolders[i] === folderPath) | |
536 return true; | |
537 } | |
538 var regex = this._manager.workspaceFolderExcludePatternSetting().asRegEx p(); | |
539 return !!(regex && regex.test(folderPath)); | |
540 }, | |
541 | |
542 /** | |
543 * @return {!Array<string>} | |
544 */ | |
545 excludedFolders: function() | |
546 { | |
547 return this._excludedFolders.slice(); | |
490 } | 548 } |
491 } | 549 } |
OLD | NEW |