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

Side by Side Diff: pkg/analyzer/lib/file_system/physical_file_system.dart

Issue 2733053002: Add support for copying directory structures (Closed)
Patch Set: Created 3 years, 9 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 analyzer.file_system.physical_file_system; 5 library analyzer.file_system.physical_file_system;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:core'; 8 import 'dart:core';
9 import 'dart:io' as io; 9 import 'dart:io' as io;
10 10
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 throw new FileSystemException(exception.path, exception.message); 143 throw new FileSystemException(exception.path, exception.message);
144 } 144 }
145 } 145 }
146 146
147 /** 147 /**
148 * Return the underlying file being represented by this wrapper. 148 * Return the underlying file being represented by this wrapper.
149 */ 149 */
150 io.File get _file => _entry as io.File; 150 io.File get _file => _entry as io.File;
151 151
152 @override 152 @override
153 File copyTo(Folder parentFolder) {
154 parentFolder.create();
155 File destination = parentFolder.getChildAssumingFile(shortName);
156 destination.writeAsBytesSync(readAsBytesSync());
157 return destination;
158 }
159
160 @override
153 Source createSource([Uri uri]) { 161 Source createSource([Uri uri]) {
154 return new FileSource(this, uri ?? pathContext.toUri(path)); 162 return new FileSource(this, uri ?? pathContext.toUri(path));
155 } 163 }
156 164
157 @override 165 @override
158 bool isOrContains(String path) { 166 bool isOrContains(String path) {
159 return path == this.path; 167 return path == this.path;
160 } 168 }
161 169
162 @override 170 @override
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 String canonicalizePath(String relPath) { 247 String canonicalizePath(String relPath) {
240 return normalize(join(path, relPath)); 248 return normalize(join(path, relPath));
241 } 249 }
242 250
243 @override 251 @override
244 bool contains(String path) { 252 bool contains(String path) {
245 return absolutePathContext.isWithin(this.path, path); 253 return absolutePathContext.isWithin(this.path, path);
246 } 254 }
247 255
248 @override 256 @override
257 Folder copyTo(Folder parentFolder) {
258 Folder destination = parentFolder.getChildAssumingFolder(shortName);
259 destination.create();
260 for (Resource child in getChildren()) {
261 child.copyTo(destination);
262 }
263 return destination;
264 }
265
266 @override
267 void create() {
268 _directory.createSync(recursive: true);
269 }
270
271 @override
249 Resource getChild(String relPath) { 272 Resource getChild(String relPath) {
250 String canonicalPath = canonicalizePath(relPath); 273 String canonicalPath = canonicalizePath(relPath);
251 return PhysicalResourceProvider.INSTANCE.getResource(canonicalPath); 274 return PhysicalResourceProvider.INSTANCE.getResource(canonicalPath);
252 } 275 }
253 276
254 @override 277 @override
255 _PhysicalFile getChildAssumingFile(String relPath) { 278 _PhysicalFile getChildAssumingFile(String relPath) {
256 String canonicalPath = canonicalizePath(relPath); 279 String canonicalPath = canonicalizePath(relPath);
257 io.File file = new io.File(canonicalPath); 280 io.File file = new io.File(canonicalPath);
258 return new _PhysicalFile(file); 281 return new _PhysicalFile(file);
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 timer.cancel(); 438 timer.cancel();
416 } 439 }
417 }); 440 });
418 return completer.future; 441 return completer.future;
419 } 442 }
420 _isSpawning = true; 443 _isSpawning = true;
421 _runner = await IsolateRunner.spawn(); 444 _runner = await IsolateRunner.spawn();
422 return _runner; 445 return _runner;
423 } 446 }
424 } 447 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/file_system/memory_file_system.dart ('k') | pkg/analyzer/test/file_system/memory_file_system_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698