Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1055)

Side by Side Diff: utils/pub/io.dart

Issue 12540010: Work around issue 9252 in scheduled_test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Also fix pkg/http. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/scheduled_test/test/utils.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 /// Creates a temp directory whose name will be based on [dir] with a unique 121 /// Creates a temp directory whose name will be based on [dir] with a unique
122 /// suffix appended to it. If [dir] is not provided, a temp directory will be 122 /// suffix appended to it. If [dir] is not provided, a temp directory will be
123 /// created in a platform-dependent temporary location. Returns the path of the 123 /// created in a platform-dependent temporary location. Returns the path of the
124 /// created directory. 124 /// created directory.
125 String createTempDir([dir = '']) { 125 String createTempDir([dir = '']) {
126 var tempDir = new Directory(dir).createTempSync(); 126 var tempDir = new Directory(dir).createTempSync();
127 log.io("Created temp directory ${tempDir.path}"); 127 log.io("Created temp directory ${tempDir.path}");
128 return tempDir.path; 128 return tempDir.path;
129 } 129 }
130 130
131 // TODO(nweiz): Remove this when issue 9252 is fixed.
131 /// Asynchronously recursively deletes [dir]. Returns a [Future] that completes 132 /// Asynchronously recursively deletes [dir]. Returns a [Future] that completes
132 /// when the deletion is done. 133 /// when the deletion is done.
133 Future<String> deleteDir(String dir) { 134 Future<String> deleteDir(String dir) {
134 return _attemptRetryable(() => log.ioAsync("delete directory $dir", 135 return _attemptRetryable(() => log.ioAsync("delete directory $dir",
135 new Directory(dir).delete(recursive: true).then((_) => dir))); 136 new Directory(dir).delete(recursive: true).then((_) => dir)));
136 } 137 }
137 138
138 /// Asynchronously lists the contents of [dir]. If [recursive] is `true`, lists 139 /// Asynchronously lists the contents of [dir]. If [recursive] is `true`, lists
139 /// subdirectory contents (defaults to `false`). If [includeHiddenFiles] is 140 /// subdirectory contents (defaults to `false`). If [includeHiddenFiles] is
140 /// `true`, includes files and directories beginning with `.` (defaults to 141 /// `true`, includes files and directories beginning with `.` (defaults to
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 // If there is a non-directory there (file or symlink), delete it. 221 // If there is a non-directory there (file or symlink), delete it.
221 deleteFile(dir); 222 deleteFile(dir);
222 return createDir(dir); 223 return createDir(dir);
223 } 224 }
224 225
225 // Just create it. 226 // Just create it.
226 return createDir(dir); 227 return createDir(dir);
227 }); 228 });
228 } 229 }
229 230
231 // TODO(nweiz): remove this when issue 9253 is fixed.
230 /// Renames (i.e. moves) the directory [from] to [to]. Returns a [Future] with 232 /// Renames (i.e. moves) the directory [from] to [to]. Returns a [Future] with
231 /// the destination directory. 233 /// the destination directory.
232 Future<String> renameDir(String from, String to) { 234 Future<String> renameDir(String from, String to) {
233 log.io("Renaming directory $from to $to."); 235 log.io("Renaming directory $from to $to.");
234 236
235 return _attemptRetryable(() => new Directory(from).rename(to)).then((dir) { 237 return _attemptRetryable(() => new Directory(from).rename(to)).then((dir) {
236 log.fine("Renamed directory $from to $to."); 238 log.fine("Renamed directory $from to $to.");
237 return to; 239 return to;
238 }); 240 });
239 } 241 }
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 const PubProcessResult(this.stdout, this.stderr, this.exitCode); 812 const PubProcessResult(this.stdout, this.stderr, this.exitCode);
811 813
812 bool get success => exitCode == 0; 814 bool get success => exitCode == 0;
813 } 815 }
814 816
815 /// Gets a [Uri] for [uri], which can either already be one, or be a [String]. 817 /// Gets a [Uri] for [uri], which can either already be one, or be a [String].
816 Uri _getUri(uri) { 818 Uri _getUri(uri) {
817 if (uri is Uri) return uri; 819 if (uri is Uri) return uri;
818 return Uri.parse(uri); 820 return Uri.parse(uri);
819 } 821 }
OLDNEW
« no previous file with comments | « pkg/scheduled_test/test/utils.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698