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

Unified Diff: utils/pub/io.dart

Issue 11299028: Move CurlClient to Pub so that it can access resources. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review change Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « utils/pub/curl_client.dart ('k') | utils/pub/utils.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/io.dart
diff --git a/utils/pub/io.dart b/utils/pub/io.dart
index 3296bb855f9562982e1b77a591362639a6d155c8..66b90b14467289bb58b687375fd9c3d75b08abc0 100644
--- a/utils/pub/io.dart
+++ b/utils/pub/io.dart
@@ -535,6 +535,19 @@ Future timeout(Future input, int milliseconds, String message) {
return completer.future;
}
+/// Creates a temporary directory and passes its path to [fn]. Once the [Future]
+/// returned by [fn] completes, the temporary directory and all its contents
+/// will be deleted.
+Future withTempDir(Future fn(String path)) {
+ var tempDir;
+ var future = new Directory('').createTemp().chain((dir) {
+ tempDir = dir;
+ return fn(tempDir.path);
+ });
+ future.onComplete((_) => tempDir.delete(recursive: true));
+ return future;
+}
+
/// Tests whether or not the git command-line app is available for use.
Future<bool> get isGitInstalled {
if (_isGitInstalledCache != null) {
« no previous file with comments | « utils/pub/curl_client.dart ('k') | utils/pub/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698