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

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

Issue 12255016: Get rid of old redundant methods in io.dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 library source; 5 library source;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8
9 import '../../pkg/path/lib/path.dart' as path;
10
8 import 'io.dart'; 11 import 'io.dart';
9 import 'package.dart'; 12 import 'package.dart';
10 import 'pubspec.dart'; 13 import 'pubspec.dart';
11 import 'system_cache.dart'; 14 import 'system_cache.dart';
12 import 'utils.dart'; 15 import 'utils.dart';
13 import 'version.dart'; 16 import 'version.dart';
14 17
15 /// A source from which to install packages. 18 /// A source from which to install packages.
16 /// 19 ///
17 /// Each source has many packages that it looks up using [PackageId]s. The 20 /// Each source has many packages that it looks up using [PackageId]s. The
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 Future<bool> install(PackageId id, String path) { 101 Future<bool> install(PackageId id, String path) {
99 throw "Either install or installToSystemCache must be implemented for " 102 throw "Either install or installToSystemCache must be implemented for "
100 "source $name."; 103 "source $name.";
101 } 104 }
102 105
103 /// Installs the package identified by [id] to the system cache. This is only 106 /// Installs the package identified by [id] to the system cache. This is only
104 /// called for sources with [shouldCache] set to true. 107 /// called for sources with [shouldCache] set to true.
105 /// 108 ///
106 /// By default, this uses [systemCacheDirectory] and [install]. 109 /// By default, this uses [systemCacheDirectory] and [install].
107 Future<Package> installToSystemCache(PackageId id) { 110 Future<Package> installToSystemCache(PackageId id) {
108 var path; 111 var packageDir;
109 return systemCacheDirectory(id).then((p) { 112 return systemCacheDirectory(id).then((p) {
110 path = p; 113 packageDir = p;
111 if (dirExists(path)) return true; 114 if (dirExists(packageDir)) return true;
112 ensureDir(dirname(path)); 115 ensureDir(path.dirname(packageDir));
113 return install(id, path); 116 return install(id, packageDir);
114 }).then((found) { 117 }).then((found) {
115 if (!found) throw 'Package $id not found.'; 118 if (!found) throw 'Package $id not found.';
116 return new Package.load(id.name, path, systemCache.sources); 119 return new Package.load(id.name, packageDir, systemCache.sources);
117 }); 120 });
118 } 121 }
119 122
120 /// Returns the directory in the system cache that the package identified by 123 /// Returns the directory in the system cache that the package identified by
121 /// [id] should be installed to. This should return a path to a subdirectory 124 /// [id] should be installed to. This should return a path to a subdirectory
122 /// of [systemCacheRoot]. 125 /// of [systemCacheRoot].
123 /// 126 ///
124 /// This doesn't need to be implemented if [shouldCache] is false. 127 /// This doesn't need to be implemented if [shouldCache] is false.
125 Future<String> systemCacheDirectory(PackageId id) { 128 Future<String> systemCacheDirectory(PackageId id) {
126 return new Future.immediateError( 129 return new Future.immediateError(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 /// according to [validateDescription], although it must still be serializable 166 /// according to [validateDescription], although it must still be serializable
164 /// to JSON and YAML. It must also be equal to [id] according to 167 /// to JSON and YAML. It must also be equal to [id] according to
165 /// [descriptionsEqual]. 168 /// [descriptionsEqual].
166 /// 169 ///
167 /// By default, this just returns [id]. 170 /// By default, this just returns [id].
168 Future<PackageId> resolveId(PackageId id) => new Future.immediate(id); 171 Future<PackageId> resolveId(PackageId id) => new Future.immediate(id);
169 172
170 /// Returns the source's name. 173 /// Returns the source's name.
171 String toString() => name; 174 String toString() => name;
172 } 175 }
OLDNEW
« utils/pub/io.dart ('K') | « utils/pub/pub.dart ('k') | utils/pub/system_cache.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698