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

Side by Side Diff: sdk/lib/_internal/pub_generated/test/descriptor/tar.dart

Issue 557563002: Store the async-await compiled pub code directly in the repo. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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
OLDNEW
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library descriptor.tar; 1 library descriptor.tar;
6
7 import 'dart:async'; 2 import 'dart:async';
8
9 import 'package:path/path.dart' as path; 3 import 'package:path/path.dart' as path;
10 import 'package:scheduled_test/scheduled_test.dart'; 4 import 'package:scheduled_test/scheduled_test.dart';
11 import 'package:scheduled_test/descriptor.dart'; 5 import 'package:scheduled_test/descriptor.dart';
12
13 import '../../lib/src/io.dart'; 6 import '../../lib/src/io.dart';
14 7 class TarFileDescriptor extends DirectoryDescriptor implements
15 /// Describes a tar file and its contents. 8 ReadableDescriptor {
16 class TarFileDescriptor extends DirectoryDescriptor
17 implements ReadableDescriptor {
18 TarFileDescriptor(String name, List<Descriptor> contents) 9 TarFileDescriptor(String name, List<Descriptor> contents)
19 : super(name, contents); 10 : super(name, contents);
20
21 /// Creates the files and directories within this tar file, then archives
22 /// them, compresses them, and saves the result to [parentDir].
23 Future<String> create([String parent]) => schedule(() { 11 Future<String> create([String parent]) => schedule(() {
24 if (parent == null) parent = defaultRoot; 12 if (parent == null) parent = defaultRoot;
25 return withTempDir((tempDir) { 13 return withTempDir((tempDir) {
26 return Future.wait(contents.map((entry) { 14 return Future.wait(contents.map((entry) {
27 return entry.create(tempDir); 15 return entry.create(tempDir);
28 })).then((_) { 16 })).then((_) {
29 var createdContents = listDir(tempDir, 17 var createdContents =
30 recursive: true, 18 listDir(tempDir, recursive: true, includeHidden: true);
31 includeHidden: true);
32 return createTarGz(createdContents, baseDir: tempDir).toBytes(); 19 return createTarGz(createdContents, baseDir: tempDir).toBytes();
33 }).then((bytes) { 20 }).then((bytes) {
34 var file = path.join(parent, name); 21 var file = path.join(parent, name);
35 writeBinaryFile(file, bytes); 22 writeBinaryFile(file, bytes);
36 return file; 23 return file;
37 }); 24 });
38 }); 25 });
39 }, 'creating tar file:\n${describe()}'); 26 }, 'creating tar file:\n${describe()}');
40
41 /// Validates that the `.tar.gz` file at [path] contains the expected
42 /// contents.
43 Future validate([String parent]) { 27 Future validate([String parent]) {
44 throw new UnimplementedError("TODO(nweiz): implement this"); 28 throw new UnimplementedError("TODO(nweiz): implement this");
45 } 29 }
46
47 Stream<List<int>> read() { 30 Stream<List<int>> read() {
48 return new Stream<List<int>>.fromFuture(withTempDir((tempDir) { 31 return new Stream<List<int>>.fromFuture(withTempDir((tempDir) {
49 return create(tempDir).then((_) => 32 return create(
50 readBinaryFile(path.join(tempDir, name))); 33 tempDir).then((_) => readBinaryFile(path.join(tempDir, name)));
51 })); 34 }));
52 } 35 }
53 } 36 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698