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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 194 |
195 /// Returns whether [dir] exists on the file system. This will return `true` for | 195 /// Returns whether [dir] exists on the file system. This will return `true` for |
196 /// a symlink only if that symlink is unbroken and points to a directory. | 196 /// a symlink only if that symlink is unbroken and points to a directory. |
197 bool dirExists(String dir) => new Directory(dir).existsSync(); | 197 bool dirExists(String dir) => new Directory(dir).existsSync(); |
198 | 198 |
199 /// Deletes whatever's at [path], whether it's a file, directory, or symlink. If | 199 /// Deletes whatever's at [path], whether it's a file, directory, or symlink. If |
200 /// it's a directory, it will be deleted recursively. | 200 /// it's a directory, it will be deleted recursively. |
201 void deleteEntry(String path) { | 201 void deleteEntry(String path) { |
202 if (linkExists(path)) { | 202 if (linkExists(path)) { |
203 log.io("Deleting link $path."); | 203 log.io("Deleting link $path."); |
204 new Link(path).deleteSync(); | 204 if (Platform.operatingSystem == 'windows') { |
| 205 // TODO(nweiz): remove this when issue 9278 is fixed. |
| 206 new Directory(path).deleteSync(); |
| 207 } else { |
| 208 new Link(path).deleteSync(); |
| 209 } |
205 } else if (dirExists(path)) { | 210 } else if (dirExists(path)) { |
206 log.io("Deleting directory $path."); | 211 log.io("Deleting directory $path."); |
207 new Directory(path).deleteSync(recursive: true); | 212 new Directory(path).deleteSync(recursive: true); |
208 } else { | 213 } else { |
209 log.io("Deleting file $path."); | 214 log.io("Deleting file $path."); |
210 new File(path).deleteSync(); | 215 new File(path).deleteSync(); |
211 } | 216 } |
212 } | 217 } |
213 | 218 |
214 /// "Cleans" [dir]. If that directory already exists, it will be deleted. Then a | 219 /// "Cleans" [dir]. If that directory already exists, it will be deleted. Then a |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 const PubProcessResult(this.stdout, this.stderr, this.exitCode); | 771 const PubProcessResult(this.stdout, this.stderr, this.exitCode); |
767 | 772 |
768 bool get success => exitCode == 0; | 773 bool get success => exitCode == 0; |
769 } | 774 } |
770 | 775 |
771 /// Gets a [Uri] for [uri], which can either already be one, or be a [String]. | 776 /// Gets a [Uri] for [uri], which can either already be one, or be a [String]. |
772 Uri _getUri(uri) { | 777 Uri _getUri(uri) { |
773 if (uri is Uri) return uri; | 778 if (uri is Uri) return uri; |
774 return Uri.parse(uri); | 779 return Uri.parse(uri); |
775 } | 780 } |
OLD | NEW |