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

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

Issue 12253054: Get rid of join() and encapsulate File and Directory in io.dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase. 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
« no previous file with comments | « utils/pub/sdk_source.dart ('k') | utils/pub/system_cache.dart » ('j') | 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) 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 8
9 import '../../pkg/path/lib/path.dart' as path; 9 import '../../pkg/path/lib/path.dart' as path;
10 10
(...skipping 29 matching lines...) Expand all
40 assert(_systemCache != null); 40 assert(_systemCache != null);
41 return _systemCache; 41 return _systemCache;
42 } 42 }
43 43
44 /// The system cache variable. Set by [_bind]. 44 /// The system cache variable. Set by [_bind].
45 SystemCache _systemCache; 45 SystemCache _systemCache;
46 46
47 /// The root directory of this source's cache within the system cache. 47 /// The root directory of this source's cache within the system cache.
48 /// 48 ///
49 /// This shouldn't be overridden by subclasses. 49 /// This shouldn't be overridden by subclasses.
50 String get systemCacheRoot => join(systemCache.rootDir, name); 50 String get systemCacheRoot => path.join(systemCache.rootDir, name);
51 51
52 /// Records the system cache to which this source belongs. 52 /// Records the system cache to which this source belongs.
53 /// 53 ///
54 /// This should only be called once for each source, by 54 /// This should only be called once for each source, by
55 /// [SystemCache.register]. It should not be overridden by base classes. 55 /// [SystemCache.register]. It should not be overridden by base classes.
56 void bind(SystemCache systemCache) { 56 void bind(SystemCache systemCache) {
57 assert(_systemCache == null); 57 assert(_systemCache == null);
58 this._systemCache = systemCache; 58 this._systemCache = systemCache;
59 } 59 }
60 60
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 /// that symlink. 137 /// that symlink.
138 /// 138 ///
139 /// This tries to determine if the cached package at [packageDir] has been 139 /// This tries to determine if the cached package at [packageDir] has been
140 /// corrupted. The heuristics are it is corrupted if any of the following are 140 /// corrupted. The heuristics are it is corrupted if any of the following are
141 /// true: 141 /// true:
142 /// 142 ///
143 /// * It has an empty "lib" directory. 143 /// * It has an empty "lib" directory.
144 /// * It has no pubspec. 144 /// * It has no pubspec.
145 Future<bool> _isCachedPackageCorrupted(String packageDir) { 145 Future<bool> _isCachedPackageCorrupted(String packageDir) {
146 return defer(() { 146 return defer(() {
147 if (!fileExists(join(packageDir, "pubspec.yaml"))) return true; 147 if (!fileExists(path.join(packageDir, "pubspec.yaml"))) return true;
148 148
149 var libDir = join(packageDir, "lib"); 149 var libDir = path.join(packageDir, "lib");
150 if (dirExists(libDir)) { 150 if (dirExists(libDir)) {
151 return listDir(libDir).then((contents) => contents.length == 0); 151 return listDir(libDir).then((contents) => contents.length == 0);
152 } 152 }
153 153
154 // If we got here, it's OK. 154 // If we got here, it's OK.
155 return false; 155 return false;
156 }); 156 });
157 } 157 }
158 158
159 /// Returns the directory in the system cache that the package identified by 159 /// Returns the directory in the system cache that the package identified by
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 /// according to [validateDescription], although it must still be serializable 202 /// according to [validateDescription], although it must still be serializable
203 /// to JSON and YAML. It must also be equal to [id] according to 203 /// to JSON and YAML. It must also be equal to [id] according to
204 /// [descriptionsEqual]. 204 /// [descriptionsEqual].
205 /// 205 ///
206 /// By default, this just returns [id]. 206 /// By default, this just returns [id].
207 Future<PackageId> resolveId(PackageId id) => new Future.immediate(id); 207 Future<PackageId> resolveId(PackageId id) => new Future.immediate(id);
208 208
209 /// Returns the source's name. 209 /// Returns the source's name.
210 String toString() => name; 210 String toString() => name;
211 } 211 }
OLDNEW
« no previous file with comments | « utils/pub/sdk_source.dart ('k') | utils/pub/system_cache.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698