OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * Namespace for utility functions. | 6 * Namespace for utility functions. |
7 */ | 7 */ |
8 var util = { | 8 var util = { |
9 /** | 9 /** |
10 * Returns a function that console.log's its arguments, prefixed by |msg|. | 10 * Returns a function that console.log's its arguments, prefixed by |msg|. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 return str.replace(/&(lt|gt|amp);/g, function(entity) { | 61 return str.replace(/&(lt|gt|amp);/g, function(entity) { |
62 switch (entity) { | 62 switch (entity) { |
63 case '<': return '<'; | 63 case '<': return '<'; |
64 case '>': return '>'; | 64 case '>': return '>'; |
65 case '&': return '&'; | 65 case '&': return '&'; |
66 } | 66 } |
67 }); | 67 }); |
68 }, | 68 }, |
69 | 69 |
70 /** | 70 /** |
71 * Given a list of Entries, recurse any DirectoryEntries, and call back | 71 * Given a list of Entries, recurse any DirectoryEntries if |recurse| is true, |
72 * with a list of all file and directory entries encountered (including the | 72 * and call back with a list of all file and directory entries encountered |
73 * original set). | 73 * (including the original set). |
74 */ | 74 */ |
75 recurseAndResolveEntries: function(entries, successCallback, errorCallback) { | 75 recurseAndResolveEntries: function(entries, recurse, |
| 76 successCallback, errorCallback) { |
76 var pendingSubdirectories = 0; | 77 var pendingSubdirectories = 0; |
77 var pendingFiles = 0; | 78 var pendingFiles = 0; |
78 | 79 |
79 var dirEntries = []; | 80 var dirEntries = []; |
80 var fileEntries = []; | 81 var fileEntries = []; |
81 var fileBytes = 0; | 82 var fileBytes = 0; |
82 | 83 |
83 function pathCompare(a, b) { | 84 function pathCompare(a, b) { |
84 if (a.fullPath > b.fullPath) | 85 if (a.fullPath > b.fullPath) |
85 return 1; | 86 return 1; |
(...skipping 16 matching lines...) Expand all Loading... |
102 | 103 |
103 if (successCallback) { | 104 if (successCallback) { |
104 successCallback(result); | 105 successCallback(result); |
105 } | 106 } |
106 } | 107 } |
107 } | 108 } |
108 | 109 |
109 function tallyEntry(entry) { | 110 function tallyEntry(entry) { |
110 if (entry.isDirectory) { | 111 if (entry.isDirectory) { |
111 dirEntries.push(entry); | 112 dirEntries.push(entry); |
112 recurseDirectory(entry); | 113 if (recurse) { |
| 114 recurseDirectory(entry); |
| 115 } |
113 } else { | 116 } else { |
114 fileEntries.push(entry); | 117 fileEntries.push(entry); |
115 pendingFiles++; | 118 pendingFiles++; |
116 entry.getMetadata(function(metadata) { | 119 entry.getMetadata(function(metadata) { |
117 fileBytes += metadata.size; | 120 fileBytes += metadata.size; |
118 pendingFiles--; | 121 pendingFiles--; |
119 areWeThereYet(); | 122 areWeThereYet(); |
120 }); | 123 }); |
121 } | 124 } |
122 } | 125 } |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 * @param {Event} event | 513 * @param {Event} event |
511 * @return {string} | 514 * @return {string} |
512 */ | 515 */ |
513 getKeyModifiers: function(event) { | 516 getKeyModifiers: function(event) { |
514 return (event.ctrlKey ? 'Ctrl-' : '') + | 517 return (event.ctrlKey ? 'Ctrl-' : '') + |
515 (event.altKey ? 'Alt-' : '') + | 518 (event.altKey ? 'Alt-' : '') + |
516 (event.shiftKey ? 'Shift-' : '') + | 519 (event.shiftKey ? 'Shift-' : '') + |
517 (event.metaKey ? 'Meta-' : ''); | 520 (event.metaKey ? 'Meta-' : ''); |
518 } | 521 } |
519 }; | 522 }; |
OLD | NEW |