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 pub.io; | 6 library pub.io; |
7 | 7 |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'dart:collection'; | 9 import 'dart:collection'; |
10 import 'dart:convert'; | 10 import 'dart:convert'; |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 /// exist, creates them. | 209 /// exist, creates them. |
210 String ensureDir(String dirPath) { | 210 String ensureDir(String dirPath) { |
211 log.fine("Ensuring directory $dirPath exists."); | 211 log.fine("Ensuring directory $dirPath exists."); |
212 var dir = new Directory(dirPath); | 212 var dir = new Directory(dirPath); |
213 if (dirPath == '.' || dirExists(dirPath)) return dirPath; | 213 if (dirPath == '.' || dirExists(dirPath)) return dirPath; |
214 | 214 |
215 ensureDir(path.dirname(dirPath)); | 215 ensureDir(path.dirname(dirPath)); |
216 | 216 |
217 try { | 217 try { |
218 createDir(dirPath); | 218 createDir(dirPath); |
219 } on DirectoryException catch (ex) { | 219 } on FileSystemException catch (ex) { |
220 // Error 17 means the directory already exists (or 183 on Windows). | 220 // Error 17 means the directory already exists (or 183 on Windows). |
221 if (ex.osError.errorCode == 17 || ex.osError.errorCode == 183) { | 221 if (ex.osError.errorCode == 17 || ex.osError.errorCode == 183) { |
222 log.fine("Got 'already exists' error when creating directory."); | 222 log.fine("Got 'already exists' error when creating directory."); |
223 } else { | 223 } else { |
224 throw ex; | 224 throw ex; |
225 } | 225 } |
226 } | 226 } |
227 | 227 |
228 return dirPath; | 228 return dirPath; |
229 } | 229 } |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 const PubProcessResult(this.stdout, this.stderr, this.exitCode); | 834 const PubProcessResult(this.stdout, this.stderr, this.exitCode); |
835 | 835 |
836 bool get success => exitCode == 0; | 836 bool get success => exitCode == 0; |
837 } | 837 } |
838 | 838 |
839 /// Gets a [Uri] for [uri], which can either already be one, or be a [String]. | 839 /// Gets a [Uri] for [uri], which can either already be one, or be a [String]. |
840 Uri _getUri(uri) { | 840 Uri _getUri(uri) { |
841 if (uri is Uri) return uri; | 841 if (uri is Uri) return uri; |
842 return Uri.parse(uri); | 842 return Uri.parse(uri); |
843 } | 843 } |
OLD | NEW |