OLD | NEW |
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 import 'dart:io'; | 5 import 'dart:io'; |
6 | 6 |
7 import 'package:path/path.dart' as p; | 7 import 'package:path/path.dart' as p; |
8 | 8 |
9 import 'io.dart'; | 9 import 'io.dart'; |
10 import 'io.dart' as io show createTempDir; | 10 import 'io.dart' as io show createTempDir; |
11 import 'log.dart' as log; | 11 import 'log.dart' as log; |
12 import 'package.dart'; | 12 import 'package.dart'; |
13 import 'source/cached.dart'; | 13 import 'source/cached.dart'; |
14 import 'source/git.dart'; | 14 import 'source/git.dart'; |
15 import 'source/hosted.dart'; | 15 import 'source/hosted.dart'; |
16 import 'source/path.dart'; | 16 import 'source/path.dart'; |
| 17 import 'source/sdk.dart'; |
17 import 'source/unknown.dart'; | 18 import 'source/unknown.dart'; |
18 import 'source.dart'; | 19 import 'source.dart'; |
19 import 'source_registry.dart'; | 20 import 'source_registry.dart'; |
20 | 21 |
21 /// The system-wide cache of downloaded packages. | 22 /// The system-wide cache of downloaded packages. |
22 /// | 23 /// |
23 /// This cache contains all packages that are downloaded from the internet. | 24 /// This cache contains all packages that are downloaded from the internet. |
24 /// Packages that are available locally (e.g. path dependencies) don't use this | 25 /// Packages that are available locally (e.g. path dependencies) don't use this |
25 /// cache. | 26 /// cache. |
26 class SystemCache { | 27 class SystemCache { |
(...skipping 25 matching lines...) Expand all Loading... |
52 /// The built-in Git source bound to this cache. | 53 /// The built-in Git source bound to this cache. |
53 BoundGitSource get git => _boundSources[sources.git] as BoundGitSource; | 54 BoundGitSource get git => _boundSources[sources.git] as BoundGitSource; |
54 | 55 |
55 /// The built-in hosted source bound to this cache. | 56 /// The built-in hosted source bound to this cache. |
56 BoundHostedSource get hosted => | 57 BoundHostedSource get hosted => |
57 _boundSources[sources.hosted] as BoundHostedSource; | 58 _boundSources[sources.hosted] as BoundHostedSource; |
58 | 59 |
59 /// The built-in path source bound to this cache. | 60 /// The built-in path source bound to this cache. |
60 BoundPathSource get path => _boundSources[sources.path] as BoundPathSource; | 61 BoundPathSource get path => _boundSources[sources.path] as BoundPathSource; |
61 | 62 |
| 63 /// The built-in SDK source bound to this cache. |
| 64 BoundSdkSource get sdk => _boundSources[sources.sdk] as BoundSdkSource; |
| 65 |
62 /// The default source bound to this cache. | 66 /// The default source bound to this cache. |
63 BoundSource get defaultSource => source(sources[null]); | 67 BoundSource get defaultSource => source(sources[null]); |
64 | 68 |
65 /// Creates a system cache and registers all sources in [sources]. | 69 /// Creates a system cache and registers all sources in [sources]. |
66 /// | 70 /// |
67 /// If [isOffline] is `true`, then the offline hosted source will be used. | 71 /// If [isOffline] is `true`, then the offline hosted source will be used. |
68 /// Defaults to `false`. | 72 /// Defaults to `false`. |
69 SystemCache({String rootDir, bool isOffline: false}) | 73 SystemCache({String rootDir, bool isOffline: false}) |
70 : rootDir = rootDir == null ? SystemCache.defaultDir : rootDir { | 74 : rootDir = rootDir == null ? SystemCache.defaultDir : rootDir { |
71 for (var source in sources.all) { | 75 for (var source in sources.all) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 var temp = ensureDir(tempDir); | 118 var temp = ensureDir(tempDir); |
115 return io.createTempDir(temp, 'dir'); | 119 return io.createTempDir(temp, 'dir'); |
116 } | 120 } |
117 | 121 |
118 /// Deletes the system cache's internal temp directory. | 122 /// Deletes the system cache's internal temp directory. |
119 void deleteTempDir() { | 123 void deleteTempDir() { |
120 log.fine('Clean up system cache temp directory $tempDir.'); | 124 log.fine('Clean up system cache temp directory $tempDir.'); |
121 if (dirExists(tempDir)) deleteEntry(tempDir); | 125 if (dirExists(tempDir)) deleteEntry(tempDir); |
122 } | 126 } |
123 } | 127 } |
OLD | NEW |