OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /// Helper functionality to make working with IO easier. | 5 /// Helper functionality to make working with IO easier. |
6 library io; | 6 library io; |
7 | 7 |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'dart:io'; | 9 import 'dart:io'; |
10 import 'dart:isolate'; | 10 import 'dart:isolate'; |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 var lister = new Directory(dir).list(); | 159 var lister = new Directory(dir).list(); |
160 | 160 |
161 var children = []; | 161 var children = []; |
162 lister.listen( | 162 lister.listen( |
163 (entity) { | 163 (entity) { |
164 if (entity is File) { | 164 if (entity is File) { |
165 var file = entity.path; | 165 var file = entity.path; |
166 if (!includeHiddenFiles && path.basename(file).startsWith('.')) { | 166 if (!includeHiddenFiles && path.basename(file).startsWith('.')) { |
167 return; | 167 return; |
168 } | 168 } |
169 contents.add(path.join(dir, path.basename(file))); | 169 contents.add(file); |
170 } else if (entity is Directory) { | 170 } else if (entity is Directory) { |
171 var file = entity.path; | 171 var file = entity.path; |
172 if (!includeHiddenFiles && path.basename(file).startsWith('.')) { | 172 if (!includeHiddenFiles && path.basename(file).startsWith('.')) { |
173 return; | 173 return; |
174 } | 174 } |
175 file = path.join(dir, path.basename(file)); | |
176 contents.add(file); | 175 contents.add(file); |
177 // TODO(nweiz): don't manually recurse once issue 7358 is fixed. | 176 // TODO(nweiz): don't manually recurse once issue 4794 is fixed. |
178 // Note that once we remove the manual recursion, we'll need to | 177 // Note that once we remove the manual recursion, we'll need to |
179 // explicitly filter out files in hidden directories. | 178 // explicitly filter out files in hidden directories. |
180 if (recursive) { | 179 if (recursive) { |
181 children.add(doList(file, listedDirectories)); | 180 children.add(doList(file, listedDirectories)); |
182 } | 181 } |
183 } | 182 } |
184 }, | 183 }, |
185 onDone: () { | 184 onDone: () { |
186 // TODO(rnystrom): May need to sort here if it turns out | 185 // TODO(rnystrom): May need to sort here if it turns out |
187 // onDir and onFile aren't guaranteed to be called in a | 186 // onDir and onFile aren't guaranteed to be called in a |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 const PubProcessResult(this.stdout, this.stderr, this.exitCode); | 767 const PubProcessResult(this.stdout, this.stderr, this.exitCode); |
769 | 768 |
770 bool get success => exitCode == 0; | 769 bool get success => exitCode == 0; |
771 } | 770 } |
772 | 771 |
773 /// Gets a [Uri] for [uri], which can either already be one, or be a [String]. | 772 /// Gets a [Uri] for [uri], which can either already be one, or be a [String]. |
774 Uri _getUri(uri) { | 773 Uri _getUri(uri) { |
775 if (uri is Uri) return uri; | 774 if (uri is Uri) return uri; |
776 return Uri.parse(uri); | 775 return Uri.parse(uri); |
777 } | 776 } |
OLD | NEW |